-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathappstudiosetup
73 lines (54 loc) · 1.69 KB
/
appstudiosetup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env bash
# Experimental App Studio setup script.
# Invoke with curl https://raw.githubusercontent.com/qmacro/dotfiles/master/appstudiosetup | bash
# when in the terminal of a new App Studio dev space.
set -o errexit
# Script-global vars
declare dotfiles="$HOME/.dotfiles"
declare backupdir="$HOME/.appstudiosetup.backups"
declare execdir="$HOME/bin"
declare jqrelease="jq-1.6"
# Make backup of a file (not even sure if backups are really neccessary,
# as this is for a freshly minted dev space.
# Note path chars (/) are turned into dashes.
backup() {
if [[ -e "$HOME/$1" ]]; then
local file
file="$(echo "$1" | tr '\/' '-')"
cp "$HOME/$1" "$backupdir/$file"
fi
}
# Bring in and set up dotfiles
setup_dotfiles() {
rm -rf "$dotfiles"
git clone https://github.com/qmacro/dotfiles.git "$dotfiles"
ln -s -f "$dotfiles/bashrc" "$HOME/.bashrc"
ln -s -f "$dotfiles/bashrc.d" "$HOME/.bashrc.d"
}
setup_dirs() {
[[ -d "$backupdir" ]] || mkdir "$backupdir"
[[ -d "$execdir" ]] || mkdir "$execdir"
}
# Configure dev space as I like it
modify_theia_settings() {
ln -s -f "$dotfiles/.theia/settings.json" "$HOME/.theia/"
ln -s -f "$dotfiles/.theia/keymaps.json" "$HOME/.theia/"
}
# Install common utilities
# ------------------------
install_utils() {
# jq - for JSON parsing and manipulation
local target="$execdir/jq"
curl -s -L "https://github.com/stedolan/jq/releases/download/${jqrelease}/jq-linux64" > "$target" && chmod +x "$target"
# jwt - for decoding JSON Web Tokens (OAuth access tokens)
npm install --global jwt-cli
}
main() {
setup_dirs
backup ".bashrc"
backup ".theia/settings.json"
setup_dotfiles
modify_theia_settings
install_utils
}
main "$@"