-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·273 lines (236 loc) · 7.4 KB
/
Copy pathbootstrap.sh
File metadata and controls
executable file
·273 lines (236 loc) · 7.4 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
#!/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() {
local force="${1:-false}"
# Skip if .gitconfig already exists and not forced
if [ "$force" != "true" ] && [ -f "$HOME/.gitconfig" ]; then
info "Git already configured, skipping (use --gitconfig to reconfigure)"
return
fi
info "Configuring Git"
# Try to get the user's full name from the OS
if [ "$(uname)" == "Darwin" ]; then
OS_NAME=$(id -F 2>/dev/null || echo "")
else
OS_NAME=$(getent passwd "$USER" 2>/dev/null | cut -d: -f5 | cut -d, -f1 || echo "")
fi
# Prompt for name (pre-filled with OS name if available)
if [ -n "$OS_NAME" ]; then
read -p "Full name [$OS_NAME]: " GIT_NAME
GIT_NAME="${GIT_NAME:-$OS_NAME}"
else
read -p "Full name: " GIT_NAME
fi
read -p "Email: " GIT_EMAIL
read -p "GitHub username: " GIT_GITHUB_USER
# Generate .gitconfig from template
sed -e "s/GIT_USER_NAME/$GIT_NAME/" \
-e "s/GIT_USER_EMAIL/$GIT_EMAIL/" \
-e "s/GIT_GITHUB_USER/$GIT_GITHUB_USER/" \
"$DOTFILES/.gitconfig.template" > "$HOME/.gitconfig"
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" \
--exclude ".exports.local" \
--exclude ".exports" \
--exclude ".gitconfig" \
--exclude ".gitconfig.template" \
--exclude ".ghostty" \
--exclude ".alacritty.toml" \
--exclude ".aerospace.toml" \
--exclude ".mise.toml" \
--exclude ".zshrc" \
--exclude ".aliases" \
--filter=':- .gitignore' \
-avh --no-perms . ~;
cp -n .exports.local $HOME/.exports.local
touch $HOME/.aliases.local
# 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}
mkdir -p $HOME/.config/ghostty
ln -sf $DOTFILES/.zshrc $HOME/.zshrc
ln -sf $DOTFILES/.aerospace.toml $HOME/.aerospace.toml
ln -sf $DOTFILES/.aliases $HOME/.aliases
ln -sf $DOTFILES/.mise.toml $HOME/.mise.toml
ln -sf $DOTFILES/.alacritty.toml $HOME/.alacritty.toml
ln -sf $DOTFILES/.exports $HOME/.exports
ln -sf $DOTFILES/.ghostty $HOME/.config/ghostty/config
ln -sf $DOTFILES/.tmux.conf $HOME/.tmux.conf
}
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)"
# ZshAutoSuggestions
# Check if zsh-autosuggestions is already installed
if [ -d "${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions" ]; then
info "zsh-autosuggestions already installed, skipping."
else
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
fi
# plug.vim
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# tmux Plugin Manager
if [ -d ~/.tmux/plugins/tpm ]; then
info "tpm already installed, skipping."
else
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
fi
~/.tmux/plugins/tpm/scripts/install_plugins.sh
# Install Neovim
DEST="${XDG_CONFIG_HOME:-$HOME/.config}/nvim"
#Remove existing directory if it exists
[ -d "$DEST" ] && rm -rf "$DEST"
git clone https://github.com/paniko0/kickstart.nvim.git "$DEST"
# Alacritty themes
mkdir -p $HOME/.config/alacritty
curl -LO --output-dir $HOME/.config/alacritty https://github.com/catppuccin/alacritty/raw/main/catppuccin-macchiato.toml
# Install programming languages
mise install
}
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
# Check if the file does not exist at the destination
if [ ! -f "$fonts/$(basename "$file")" ]; then
cp -v "$file" "$fonts"
fi
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() {
if ! command -v brew &> /dev/null
then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
brew bundle --file=Brewfile
}
doThemes() {
info "ZSH - copying modified af-magic"
cp $DOTFILES/themes/af-magic.zsh-theme $HOME/.oh-my-zsh/custom/themes/af-magic.zsh-theme
}
doAll() {
doUpdate
doBrew
doSync
doThemes
doGitConfig
doDirectories
doSymLink
doInstall
doFonts
doConfig
}
doHelp() {
echo "Usage: $(basename "$0") [options]" >&2
echo
echo " -s, --sync Synchronizes dotfiles to home directory"
echo " -t, --themes Synchronizes themes"
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 " -g, --gitconfig Force reconfigure git identity"
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
;;
-t|--themes)
doThemes
shift
;;
-l|--link)
doSymLink
shift
;;
-i|--install)
doInstall
doBrew
shift
;;
-f|--fonts)
doFonts
shift
;;
-c|--config)
doConfig
shift
;;
-g|--gitconfig)
doGitConfig true
shift
;;
-a|--all)
doAll
shift
;;
*)
doHelp
shift
;;
esac
done
fi