-
Notifications
You must be signed in to change notification settings - Fork 0
/
dotfiles.sh
executable file
·502 lines (450 loc) · 11.5 KB
/
dotfiles.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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
#!/bin/bash
DOTFILES=$(pwd) # dotfiles repo location defaults to current directory
OS=$OSTYPE
if [[ ${OS:0:6} == "darwin" ]]; then
OS="darwin"
elif [[ ${OS:0:5} == "linux" ]]; then
OS="linux"
fi
LINK_MSG="Linking config files for"
UNLINK_MSG="Unlinking config files for"
#-----------------------------------------------------------------------------#
function usage() {
echo "Usage:"
echo " ./dotfiles.sh help"
echo " ./dotfiles.sh setup"
echo " ./dotfiles.sh link TARGET"
echo " ./dotfiles.sh unlink TARGET"
echo " ./dotfiles.sh relink TARGET"
echo ""
echo "TARGET may be one of:"
echo " bash | emacs | git | htop | i3 | jrnl | kak | mc | nvim | tmux | vim | weechat | xorg | zsh"
echo ""
echo "Debug:"
echo " " HOME=$HOME
echo " " DOTFILES=$DOTFILES
echo " " OS=$OS
echo " " ARG0=$0
echo " " ARG1=$1
echo " " ARG2=$2
}
#-----------------------------------------------------------------------------#
function setup() {
# if [[ $OS == "linux" ]]; then
# fi
if [[ $OS == "darwin" ]]; then
echo "Installing xcode"
xcode-select --install
echo "Installing brew"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/igaray/.zprofile
echo "Installing CLI utilities"
brew install \
ansible \
coreutils \
csvkit \
curl \
direnv \
fdupes \
ffmpeg \
fzf \
gcc \
gdb \
git \
glances \
google-cloud-sdk \
htop \
jq \
jrnl \
jsonpp \
kakoune \
kerl \
midnight-commander \
miller \
ncdu \
neovim \
nnn \
oil \
pipenv \
rar \
tmux \
tree \
tree-sitter \
wget \
xz \
zsh \
zsh-autosuggestions \
zsh-completions \
zsh-syntax-highlighting
echo "Installing GUI utilities"
brew install --cask \
1password \
amethyst \
app-cleaner \
authy \
calibre \
clickup \
cmake \
discord \
disk-inventory-x \
docker \
electrum \
emacs \
firefox \
flux \
google-chrome \
google-cloud-sdk \
kitty \
mactex \
marta \
obsidian \
postman \
qbittorrent \
rar \
signal \
simple-comic \
sizeup \
skype \
slack \
spotify \
sublime-text \
teamviewer \
telegram \
visual-studio-code \
vlc \
yed \
zoom \
zulip
# Config zsh
chmod -R go-w '/opt/homebrew/share/zsh'
chmod -R go-w '/opt/homebrew/share'
rm -f ~/.zcompdump; compinit
fi
# OS independent commands
echo "Installing Erlang"
kerl build 23.3.4.9 23.3.4.9
kerl install 23.3.4.9 $HOME/.local/bin/erlang/23.3.4.9
echo "Installing Elixir"
\curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | bash -s
kiex install 1.11.4
kiex use 1.11.4
# echo "Installing Python"
echo "Installing Rust"
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
echo "Installing Rust utilities"
cargo install \
bandwhich \
bat \
bottom \
cargo-binutils \
cargo-bisect-rustc \
cargo-geiger \
cargo-tree \
cargo-update \
dirscan \
du-dust \
exa \
fd-find \
flamegraph \
fselect \
git-delta \
grex \
hyperfine \
mdbook \
mdbook-katex \
mdbook-mermaid \
mdbook-linkcheck \
mdbook-toc \
nu \
procs \
ripgrep \
rsys \
sccache \
starship \
tokei \
xsv \
ytop \
zenith \
zoxide
}
function download() {
wget https://dl.dropboxusercontent.com/u/9332961/kttk.sh
wget https://dl.dropboxusercontent.com/u/9332961/hoh.sh
}
#-----------------------------------------------------------------------------#
function link_bash() {
echo $LINK_MSG "bash..."
if [[ $OS == "linux" ]]; then
ln "$DOTFILES/bash/linux/.bashrc" ~/.bashrc
ln "$DOTFILES/bash/linux/.bash_logout" ~/.bash_logout
ln "$DOTFILES/bash/linux/.bash_profile" ~/.bash_profile
fi
if [[ $OS == "darwin" ]]; then
ln "$DOTFILES/bash/osx/.bashrc" ~/.bashrc
ln "$DOTFILES/bash/osx/.bash_logout" ~/.bash_logout
ln "$DOTFILES/bash/osx/.bash_profile" ~/.bash_profile
fi
}
function unlink_bash() {
echo $UNLINK_MSG "bash..."
rm -f ~/.bashrc
rm -f ~/.bash_logout
rm -f ~/.bash_profile
}
#-----------------------------------------------------------------------------#
function link_emacs() {
echo $LINK_MSG "emacs..."
ln -s "$DOTFILES/emacs/.emacs.d" ~/.emacs.d
}
function unlink_emacs() {
echo $UNLINK_MSG "emacs..."
rm -rf ~/.emacs.d
}
#-----------------------------------------------------------------------------#
function link_git() {
echo $LINK_MSG "git..."
mkdir -p ~/.local/bin
ln "$DOTFILES/git/.gitconfig" ~/.gitconfig
ln "$DOTFILES/git/.gitignore_global" ~/.gitignore_global
ln "$DOTFILES/git/diff-so-fancy" ~/.local/bin
chmod +x ~/.local/bin/diff-so-fancy
}
function unlink_git() {
echo $UNLINK_MSG "git..."
rm -f ~/.gitconfig
rm -f ~/.gitignore_global
rm -f ~/.local/bin/diff-so-fancy
}
#-----------------------------------------------------------------------------#
function link_htop() {
echo $LINK_MSG "htop..."
mkdir -p ~/.config/htop
ln "$DOTFILES/htop/htoprc" ~/.config/htop/htoprc
}
function unlink_htop() {
echo $UNLINK_MSG "htop..."
rm -rf ~/.config/htop
}
#-----------------------------------------------------------------------------#
function link_i3() {
echo $LINK_MSG "i3..."
mkdir -p ~/.config/i3
ln "$DOTFILES/i3/config" ~/.config/i3/config
}
function unlink_i3() {
echo $UNLINK_MSG "i3..."
rm -rf ~/.config/i3
}
#-----------------------------------------------------------------------------#
function link_jrnl {
echo $LINK_MSG "jrnl..."
mkdir ~/.config/jrnl
ln "$(pwd)/jrnl/jrnl.yaml" ~/.config/jrnl/jrnl.yaml
}
function unlink_jrnl {
echo $UNLINK_MSG "jrnl..."
rm -rf ~/.config/jrnl
}
#-----------------------------------------------------------------------------#
function link_kak() {
echo $LINK_MSG "kak..."
mkdir -p ~/.config/kak
ln "$DOTFILES/kak/kakrc" ~/.config/kak/kakrc
}
function unlink_kak() {
echo $UNLINK_MSG "kak..."
rm -rf ~/.config/kak
}
#-----------------------------------------------------------------------------#
function link_mc() {
echo $LINK_MSG "mc..."
mkdir -p ~/.config/mc
ln "$DOTFILES/mc/ini" ~/.config/mc/ini
ln "$DOTFILES/mc/mc.ext" ~/.config/mc/mc.ext
ln "$DOTFILES/mc/mc.keymap" ~/.config/mc/mc.keymap
ln -s "$DOTFILES/mc/skins" ~/.config/mc/skins
}
function unlink_mc() {
echo $UNLINK_MSG "mc..."
rm -rf ~/.config/mc
}
#-----------------------------------------------------------------------------#
function link_nvim() {
echo $LINK_MSG "nvim..."
mkdir -p ~/.config/nvim/{autoload,plugged}
ln "$DOTFILES/nvim/init.vim" ~/.config/nvim/init.vim
ln "$DOTFILES/nvim/autoload/plug.vim" ~/.config/nvim/autoload/plug.vim
}
function unlink_nvim() {
echo $UNLINK_MSG "nvim..."
rm -rf ~/.config/nvim
}
#-----------------------------------------------------------------------------#
function link_tmux() {
echo $LINK_MSG "tmux..."
ln "$DOTFILES/tmux/.tmux.conf" ~/.tmux.conf
}
function unlink_tmux() {
echo $UNLINK_MSG "tmux..."
rm -f ~/.tmux.conf
}
#-----------------------------------------------------------------------------#
function link_vim() {
echo $LINK_MSG "vim..."
mkdir -p ~/.vim/{backupdir,recoverydir,undodir}
ln "$DOTFILES/vim/.vimrc" ~/.vimrc
ln -s "$DOTFILES/vim/.vim/autoload" ~/.vim/autoload
ln -s "$DOTFILES/vim/.vim/bundle" ~/.vim/bundle
}
function unlink_vim() {
echo $UNLINK_MSG "vim..."
rm -f ~/.vimrc
rm -rf ~/.vim
}
#-----------------------------------------------------------------------------#
function link_weechat() {
echo $LINK_MSG "weechat..."
mkdir -p ~/.weechat
ln "$DOTFILES/weechat/alias.conf" ~/.weechat/alias.conf
ln "$DOTFILES/weechat/aspell.conf" ~/.weechat/aspell.conf
ln "$DOTFILES/weechat/charset.conf" ~/.weechat/charset.conf
ln "$DOTFILES/weechat/exec.conf" ~/.weechat/exec.conf
ln "$DOTFILES/weechat/irc.conf" ~/.weechat/irc.conf
ln "$DOTFILES/weechat/logger.conf" ~/.weechat/logger.conf
ln "$DOTFILES/weechat/plugins.conf" ~/.weechat/plugins.conf
ln "$DOTFILES/weechat/relay.conf" ~/.weechat/relay.conf
ln "$DOTFILES/weechat/rmodifier.conf" ~/.weechat/rmodifier.conf
ln "$DOTFILES/weechat/script.conf" ~/.weechat/script.conf
ln "$DOTFILES/weechat/sec.conf" ~/.weechat/sec.conf
ln "$DOTFILES/weechat/trigger.conf" ~/.weechat/trigger.conf
ln "$DOTFILES/weechat/weechat.conf" ~/.weechat/weechat.conf
ln "$DOTFILES/weechat/xfer.conf" ~/.weechat/xfer.conf
ln -s "$DOTFILES/weechat/perl" ~/.weechat/perl
ln -s "$DOTFILES/weechat/script" ~/.weechat/script
ln -s "$DOTFILES/weechat/ssl" ~/.weechat/ssl
}
function unlink_weechat() {
echo $UNLINK_MSG "weechat..."
rm -rf ~/.weechat
}
#-----------------------------------------------------------------------------#
function link_xorg() {
if [[ $OS == "linux" ]]; then
echo $LINK_MSG "xorg..."
ln "$DOTFILES/xorg/.Xdefaults" ~/.Xdefaults
ln "$DOTFILES/xorg/.xinitrc" ~/.xinitrc
fi
}
function unlink_xorg() {
if [[ $OS == "linux" ]]; then
echo $UNLINK_MSG "xorg..."
rm -f ~/.Xdefaults
rm -f ~/.xinitrc
fi
}
#-----------------------------------------------------------------------------#
function link_zsh() {
echo $LINK_MSG "zsh..."
if [[ $OS == "linux" ]]; then
ln "$DOTFILES/zsh/linux/.zlogout" ~/.zlogout
ln "$DOTFILES/zsh/linux/.zprofile" ~/.zprofile
ln "$DOTFILES/zsh/linux/.zshenv" ~/.zshenv
ln "$DOTFILES/zsh/linux/.zshrc" ~/.zshrc
fi
if [[ $OS == "darwin" ]]; then
ln "$DOTFILES/zsh/osx/.zlogout" ~/.zlogout
ln "$DOTFILES/zsh/osx/.zprofile" ~/.zprofile
ln "$DOTFILES/zsh/osx/.zshenv" ~/.zshenv
ln "$DOTFILES/zsh/osx/.zshrc" ~/.zshrc
fi
}
function unlink_zsh() {
echo $UNLINK_MSG "zsh..."
rm -f ~/.zlogout
rm -f ~/.zprofile
rm -f ~/.zshenv
rm -f ~/.zshrc
}
#-----------------------------------------------------------------------------#
function link_config() {
case $1 in
"bash") link_bash ;;
"emacs") link_emacs ;;
"git") link_git ;;
"htop") link_htop ;;
"i3") link_i3 ;;
"jrnl") link_jrnl ;;
"kak") link_kak ;;
"mc") link_mc ;;
"nvim") link_nvim ;;
"tmux") link_tmux ;;
"vim") link_vim ;;
"weechat") link_weechat ;;
"xorg") link_xorg ;;
"zsh") link_zsh ;;
*)
echo "Error: unrecognized option:" $1
usage
exit 1
esac
}
function unlink_config() {
case $1 in
"all")
unlink_bash
unlink_emacs
unlink_git
unlink_htop
unlink_i3
unlink_mc
unlink_nvim
unlink_tmux
unlink_vim
unlink_weechat
unlink_xorg
unlink_zsh
;;
"bash") unlink_bash ;;
"emacs") unlink_emacs ;;
"git") unlink_git ;;
"htop") unlink_htop ;;
"i3") unlink_i3 ;;
"kak") unlink_kak ;;
"mc") unlink_mc ;;
"nvim") unlink_nvim ;;
"tmux") unlink_tmux ;;
"vim") unlink_vim ;;
"weechat") unlink_weechat ;;
"xorg") unlink_xorg ;;
"zsh") unlink_zsh ;;
*)
echo "Error: unrecognized option:" $1
usage
exit 1
esac
}
function relink_config() {
unlink_config $1
link_config $1
}
case $1 in
"setup")
setup
;;
"link")
link_config $2
;;
"unlink")
unlink_config $2
;;
"relink")
relink_config $2
;;
""|"-h"|"--help"|"help")
usage $1 $2
;;
*)
echo "Error: unrecognized option:" $1 "\n"
usage $1 $2
exit 1
esac