-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·386 lines (326 loc) · 9.46 KB
/
setup.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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#!/bin/bash
set -e
install_homebrew() {
msg "Installing Homebrew"
if command -v brew >/dev/null; then
msg "Homebrew already installed"
else
# From https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
msg "Homebrew installed"
fi
}
install_brews() {
msg "Installing brews"
brew bundle
msg "Brews installed"
}
install_packages() {
msg "Installing packages"
while IFS= read -r line; do
sudo apt-add-repository --yes "$line"
done <"repolist"
sudo apt-get --assume-yes install $(cat pkglist)
msg "Packages installed"
}
install_node_modules() {
msg "Installing global node modules"
npm install --location=global $(cat node_list)
msg "Node modules installed"
}
install_flatpaks() {
msg "Installing Flatpaks"
# TODO first check if installed
#flatpak install --assumeyes $(cat flatpaks)
msg "Flatpaks installed"
}
install_cargoes() {
msg "Installing Cargoes"
cargo install --locked $(cat cargolist)
#cargo install-update -a
msg "Cargoes installed"
}
install_go_packages() {
msg "Installing Go packages"
while IFS= read -r package; do
go install "$package"
done <"golist"
msg "Go packages installed"
}
install_awscli() {
msg "Installing AWS CLI"
if command -v aws >/dev/null; then
_install_awscli "--update"
msg "AWS CLI upgraded"
else
_install_awscli
msg "AWS CLI installed"
fi
}
_install_awscli() {
if [[ "$OSTYPE" == "linux-gnu" ]]; then
# From https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2-linux.html
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install "$@"
rm -rf ./aws
rm awscliv2.zip
elif [[ $OSTYPE == darwin* ]]; then
curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /
rm AWSCLIV2.pkg
fi
}
install_oh_my_zsh() {
msg "Installing Oh My Zsh"
if [[ -d "$HOME/.oh-my-zsh" ]]; then
msg "Oh My Zsh already installed"
else
# From https://github.com/robbyrussell/oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
msg "Oh My Zsh installed"
fi
}
link_dotfiles() {
msg "Linking dotfiles"
local dotfiles
dotfiles=$(pwd)
local files
files=($(find . -maxdepth 1 -name '.*' -type f))
for i in "${files[@]}"; do
if [[ $i = */.DS_Store ]]; then
msg "Skipping $i"
else
local file
file=${i//^../} #"$(echo $i | sed -e 's/^..//')"
ln -fsv "$dotfiles/$file" "$HOME/$file"
fi
done
# ZSH custom setup
ln -fsv "$dotfiles/.zsh_custom" "$HOME"
# Create the nvim configuration
mkdir -p "$HOME/.config"
ln -fsvn "$dotfiles/nvim" "$HOME/.config/nvim"
# Starship
ln -fsv "$dotfiles/starship.toml" "$HOME/.config/starship.toml"
# Conky
mkdir -p "$HOME/.config/conky"
ln -fsv "$dotfiles/conky.conf" "$HOME/.config/conky/conky.conf"
# Kitty
mkdir -p "$HOME/.config/kitty"
ln -fsv "$dotfiles/kitty.conf" "$HOME/.config/kitty/kitty.conf"
# WezTerm
mkdir -p "$HOME/.config/wezterm"
ln -fsv "$dotfiles/wezterm.lua" "$HOME/.config/wezterm/wezterm.lua"
# Espanso
mkdir -p "$HOME/.config/espanso/config/"
mkdir -p "$HOME/.config/espanso/match/"
ln -fsv "$dotfiles/espanso_match.yml" "$HOME/.config/espanso/match/base.yml"
ln -fsv "$dotfiles/espanso_config.yml" "$HOME/.config/espanso/config/default.yml"
# Macchina
mkdir -p "$HOME/.config/macchina"
ln -fsv "$dotfiles/macchina.toml" "$HOME/.config/macchina/macchina.toml"
# Sublime
if [[ "$OSTYPE" == "linux-gnu" ]]; then
mkdir -p "$HOME/.config/sublime-text-3/Packages/User"
ln -fsv "$dotfiles/Preferences.sublime-settings" "$HOME/.config/sublime-text-3/Packages/User/Preferences.sublime-settings"
elif [[ $OSTYPE == darwin* ]]; then
mkdir -p "$HOME/Library/Application Support/Sublime Text/Packages/User"
ln -fsv "$dotfiles/Preferences.sublime-settings" "$HOME/Library/Application Support/Sublime Text/Packages/User/Preferences.sublime-settings"
fi
# Git
mkdir -p "$HOME/.config/git"
ln -fsv "$dotfiles/globalignore" "$HOME/.config/git/ignore"
# Zellij
mkdir -p "$HOME/.config/zellij"
ln -fsv "$dotfiles/zellij.kdl" "$HOME/.config/zellij/config.kdl"
# Nu Shell
# TODO Mac uses /Users/rwarner/Library/Application Support/nushell/env.nu
mkdir -p "$HOME/.config/nushell"
ln -fsv "$dotfiles/nushell/config.nu" "$HOME/.config/nushell/config.nu"
ln -fsv "$dotfiles/nushell/env.nu" "$HOME/.config/nushell/env.nu"
ln -fsv "$dotfiles/nushell/plugin.nu" "$HOME/.config/nushell/plugin.nu"
# atuin
mkdir -p "$HOME/.config/atuin"
ln -fsv "$dotfiles/atuin/config.toml" "$HOME/.config/atuin/config.toml"
ln -fsv "$dotfiles/atuin/init.nu" "$HOME/.config/atuin/init.nu"
# zed
mkdir -p "$HOME/.config/zed"
ln -fsv "$dotfiles/zed.json" "$HOME/.config/zed/settings.json"
# jujutusu
mkdir -p "$HOME/,config/jj"
ln -fsv "$dotfiles/jj.toml" "$HOME/.config/jj/config.toml"
msg "Dotfiles linked"
}
install_terminfos() {
local terminfos=(
"xterm-256color-italic"
"tmux-256color"
)
for i in "${terminfos[@]}"; do
msg "Installing terminfo $i"
if infocmp "$i" >/dev/null 2>&1; then
msg "terminfo $i already installed"
else
if [[ $i == tmux* ]]; then
echo "$i|tmux with 256 colors and italic," >"$TMPDIR/$i.terminfo"
echo " ritm=\E[23m, rmso=\E[27m, sitm=\E[3m, smso=\E[7m, Ms@," >>"$TMPDIR/$i.terminfo"
echo " khome=\E[1~, kend=\E[4~," >>"$TMPDIR/$i.terminfo"
echo " use=xterm-256color, use=screen-256color, " >>"$TMPDIR/$i.terminfo"
else
echo "$i|xterm with 256 colors and italic," >"$TMPDIR/$i.terminfo"
echo " sitm=\E[3m, ritm=\E[23m," >>"$TMPDIR/$i.terminfo"
echo " use=xterm-256color," >>"$TMPDIR/$i.terminfo"
fi
tic -x "$TMPDIR/$i.terminfo"
rm "$TMPDIR/$i.terminfo"
msg "Installed terminfo $i"
fi
done
msg "Terminfos installed"
}
install_tpm() {
msg "Installing tpm"
if [[ -d "$HOME/.tmux/plugins/tpm" ]]; then
msg "tpm already installed"
else
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
msg "tpm installed"
fi
}
install_font() {
msg "Installing nerd font"
if system_profiler SPFontsDataType 2>/dev/null | grep -q "Hasklug Nerd Font Complete"; then
msg "Nerd font already installed"
else
cd "$HOME/Library/Fonts" && {
curl -O https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Hasklig/Regular/complete/Hasklug%20Nerd%20Font%20Complete.otf
cd -
}
msg "Nerd font installed"
fi
}
install_starship() {
msg "Installing starship"
# From https://starship.rs -- will install or update
sudo mkdir -p /usr/local/bin
curl -sS https://starship.rs/install.sh | sh
msg "starship installed"
}
install_rust() {
msg "Installing Rust"
if command -v rustc >/dev/null; then
msg "Rust already installed"
else
# From https://www.rust-lang.org/tools/install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source $HOME/.cargo/env
msg "Rust installed"
fi
}
configure_ctags() {
msg "Configuring ctags"
mkdir -p "$HOME/.config/ctags"
local dotfiles
dotfiles=$(pwd)
local files
files=($(find . -maxdepth 1 -name '*.ctags' -type f))
for i in "${files[@]}"; do
local file
file=${i//^../} #"$(echo $i | sed -e 's/^..//')"
ln -fsv "$dotfiles/$file" "$HOME/.config/ctags/$file"
done
}
configure_git() {
msg "Configuring git"
local name
name="$(git config --global --includes user.name)" || true
if [[ -z "$name" ]]; then
echo "Enter your full name:"
read -r name
echo "Enter your email address:"
read -r email
echo "[user]" >>"$HOME/.gitconfig.local"
echo " name = $name" >>"$HOME/.gitconfig.local"
echo " email = $email" >>"$HOME/.gitconfig.local"
msg "git configured"
else
msg "git already configured"
fi
}
configure_neovim() {
msg "Configuring Neovim"
pip install --upgrade pip pynvim
npm install --location=global neovim
gem install neovim
msg "Neovim configured"
}
configure_flatpak() {
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
}
enable_gtk_inspector() {
gsettings set org.gtk.Settings.Debug enable-inspector-keybinding true
}
link_fd() {
ln -fsv "$(which fdfind)" ~/bin/fd
}
install_asdf() {
if command -v asdf >/dev/null; then
msg "Updating asdf"
cd "$HOME/.asdf"
git pull
cd -
else
msg "Installing asdf"
git clone https://github.com/asdf-vm/asdf.git "$HOME/.asdf"
fi
}
msg() {
if [[ "$1" != "" ]]; then
echo "[$(date +'%T')]" "$1"
fi
}
main() {
if [[ "$OSTYPE" == "linux-gnu" ]]; then
install_oh_my_zsh
link_dotfiles
install_packages
install_starship
install_rust
install_cargoes
install_go_packages
install_node_modules
install_awscli
install_tpm
install_asdf
configure_ctags
configure_git
configure_neovim
configure_flatpak
install_flatpaks
enable_gtk_inspector
link_fd
elif [[ $OSTYPE == darwin* ]]; then
install_oh_my_zsh
link_dotfiles
install_homebrew
install_starship
install_asdf
install_rust
install_cargoes
install_go_packages
install_node_modules
install_awscli
install_brews
# install_pythons
install_tpm
install_terminfos
install_font
configure_ctags
configure_git
configure_neovim
else
msg "Unrecognized operating system"
fi
}
main