-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.sh
executable file
·171 lines (148 loc) · 3.98 KB
/
bootstrap.sh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/usr/bin/env bash
# copied from https://github.com/JDevlieghere/dotfiles/blob/master/bootstrap.sh
DOTFILES=$(pwd -P)
info() {
printf "\033[00;34m$@\033[0m\n"
}
doUpdate() {
info "Updating"
git pull origin master;
}
doGitConfig() {
info "Configuring Git"
# The .gitconfig will be overwritten; reconfigure it.
echo "Configuring global .gitignore"
git config --global core.excludesfile ~/.gitignore_global
# Use Araxis Merge as diff and merge tool when available.
if [ -d "/Applications/Araxis Merge.app/Contents/Utilities/" ]; then
echo "Configuring Araxis Merge"
git config --global diff.guitool araxis
git config --global merge.guitool araxis
fi
}
doSync() {
info "Syncing"
rsync --exclude ".git/" \
--exclude ".gitignore" \
--exclude "Preferences.sublime-settings" \
--exclude "README.md" \
--exclude "bootstrap.sh" \
--exclude "installers/" \
--exclude "os/" \
--exclude "scripts/" \
--exclude "tmux.terminfo" \
--filter=':- .gitignore' \
-avh --no-perms . ~;
# Copy files that have different locations on macOS and Linux.
if [ -d "$HOME/Library/Application Support/Code/User/" ]; then
cp -f "$HOME/.config/Code/User/settings.json" \
"$HOME/Library/Application Support/Code/User/settings.json"
fi
}
doSymLink() {
mkdir -p ${XDG_CONFIG_HOME:=$HOME/.config}
}
doDirectories() {
mkdir -p ~/.vim/undo
}
doInstall() {
info "Installing Extras"
# Oh-My-Zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# plug.vim
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# tmux Plugin Manager
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
}
doFonts() {
info "Installing Fonts"
if [ "$(uname)" == "Darwin" ]; then
fonts=~/Library/Fonts
elif [ "$(uname)" == "Linux" ]; then
fonts=~/.fonts
mkdir -p "$fonts"
fi
$DOTFILES/fonts/firacode.sh
find "$DOTFILES/fonts/" -name "*.[o,t]tf" -type f | while read -r file
do
cp -v "$file" "$fonts"
done
}
doConfig() {
info "Configuring"
if [ "$(uname)" == "Darwin" ]; then
echo "Configuring macOS"
./os/macos.sh
elif [ "$(uname)" == "Linux" ]; then
echo "Configuring Linux"
./os/linux.sh
fi
}
doBrew() {
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew tap Homebrew/bundle
brew bundle --file=Brewfile
}
doAll() {
doUpdate
doBrew
doSync
doGitConfig
doDirectories
doSymLink
doInstall
doFonts
doConfig
}
doHelp() {
echo "Usage: $(basename "$0") [options]" >&2
echo
echo " -s, --sync Synchronizes dotfiles to home directory"
echo " -l, --link Create symbolic links"
echo " -i, --install Install (extra) software"
echo " -f, --fonts Copies font files"
echo " -c, --config Configures your system"
echo " -a, --all Does all of the above"
echo
exit 1
}
if [ $# -eq 0 ]; then
doAll
else
for i in "$@"
do
case $i in
-s|--sync)
doSync
doGitConfig
doDirectories
shift
;;
-l|--link)
doSymLink
shift
;;
-i|--install)
doInstall
doBrew
shift
;;
-f|--fonts)
doFonts
shift
;;
-c|--config)
doConfig
shift
;;
-a|--all)
doAll
shift
;;
*)
doHelp
shift
;;
esac
done
fi