-
Notifications
You must be signed in to change notification settings - Fork 58
/
bootstrap.sh
executable file
·192 lines (164 loc) · 4.88 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#!/usr/bin/env bash
# shellcheck disable=SC2016
DOTFILES=$(dirname "$0")
info() {
printf "\033[00;34m%s\033[0m\n" "$@"
}
doUpdate() {
info "Updating"
git pull origin main
}
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
git config --global mergetool.araxis.path /Applications/Araxis\ Merge.app/Contents/Utilities/compare
fi
# Use Sublime Merge as diff and merge tool when available.
if [ -d "/Applications/Sublime Merge.app/Contents/SharedSupport/bin/" ]; then
echo "Configuring Sublime Merge"
git config --global mergetool.smerge.cmd 'smerge mergetool "$BASE" "$LOCAL" "$REMOTE" -o "$MERGED"'
git config --global mergetool.smerge.trustExitCode true
git config --global merge.tool smerge
fi
delta=$(type -P "delta")
if [ -x "$delta" ]; then
echo "Configuring delta"
git config --global core.pager "delta"
git config --global interactive.diffFilter "delta --color-only"
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 "sublime/" \
--exclude "tmux.terminfo" \
--filter=':- .gitignore' \
--no-perms \
-avh \
"$DOTFILES/" \
"$HOME"
# Touch .localrc so fish can source it.
touch ~/.localrc
# 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}"
ln -s ~/.vim/* "$XDG_CONFIG_HOME/nvim"
ln -s ~/.vimrc "$XDG_CONFIG_HOME/nvim/init.vim"
}
doDirectories() {
mkdir -p ~/.vim/undo
mkdir -p ~/.ssh
mkdir -p ~/.gnupg
}
doInstall() {
info "Installing Extras"
# vim
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim +PlugInstall +PlugUpdate +qa!
if command -v nvim &> /dev/null; then
nvim +PlugInstall +PlugUpdate +TSUpdate +qa!
fi
# tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup-init.sh
chmod +x /tmp/rustup-init.sh
/tmp/rustup-init.sh -y
}
doPermissions() {
info "Fixing Permissions "
chown -R "$(whoami)" "$HOME/.ssh/"
find "$HOME/.ssh" -type d -exec chmod 700 {} \;
find "$HOME/.ssh" -type f -name 'id_rsa*' -exec chmod 600 {} \;
find "$HOME/.ssh" -type f -name '*.pub' -exec chmod 644 {} \;
chown -R "$(whoami)" "$HOME/.gnupg/"
find "$HOME/.gnupg" -type f -exec chmod 600 {} \;
find "$HOME/.gnupg" -type d -exec chmod 700 {} \;
}
doConfig() {
info "Configuring"
if [ "$(uname)" == "Darwin" ]; then
echo "Configuring macOS"
"$DOTFILES/os/macos.sh"
elif [ "$(uname)" == "Linux" ]; then
echo "Configuring Linux"
"$DOTFILES/os/linux.sh"
fi
}
doAll() {
doUpdate
doSync
doGitConfig
doDirectories
doPermissions
doSymLink
doInstall
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 " -c, --config Configures your system"
echo " -a, --all Does all of the above"
echo
exit 1
}
if [ $# -eq 0 ]; then
doHelp
else
for i in "$@"
do
case $i in
-s|--sync)
doSync
doGitConfig
doDirectories
doPermissions
shift
;;
-l|--link)
doSymLink
shift
;;
-i|--install)
doInstall
shift
;;
-c|--config)
doConfig
shift
;;
-a|--all)
doAll
shift
;;
*)
doHelp
shift
;;
esac
done
fi