-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy
executable file
·496 lines (405 loc) · 11.5 KB
/
deploy
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
#!/bin/bash
# PATHS ==========================================
DOTFILES_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
DIR_PROJ=~/Projects
DIR_VIMCONFIG=~/.config/nvim
DIR_HELIXCONFIG=~/.config/helix
FILE_VIMINIT=$DIR_VIMCONFIG/init.vim
DIR_VIMPLUGINS=$DIR_VIMCONFIG/plugged
DIR_ROFI=~/.config/rofi
DIR_FUZZEL=~/.config/fuzzel
DIR_TSCHUSS=~/.config/tschuss
DIR_RANGER=~/.config/ranger
DIR_NNN=~/.config/nnn
DIR_LF=~/.config/lf
DIR_YAZI=~/.config/yazi
DIR_JJ=~/.config/jj
DIR_I3=~/.config/i3
DIR_SWAY=~/.config/sway
DIR_HYPR=~/.config/hypr
DIR_WAYBAR=~/.config/waybar
DIR_POLYBAR=~/.config/polybar
DIR_I3BLOCKS=~/.config/i3blocks
DIR_XOB=~/.config/xob
DIR_KITTY=~/.config/kitty
DIR_ALACRITTY=~/.config/alacritty
DIR_ZSHPLUGINS=${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins
DIR_FISH=~/.config/fish
DIR_STARSHIP=~/.config
DIR_MPD=~/.config/mpd
DIR_NCMPCPP=~/.config/ncmpcpp
DIR_VIS=~/.config/vis
DIR_NEWSBOAT=~/.config/newsboat
DIR_MUTT=~/.config/mutt
# HELPERS ========================================
function echo-debug { echo "$@" | sed -e "s%$HOME%~%g" -e "s%$DOTFILES%.%g"; }
function echo-info { printf "\r\033[2K\033[0;34m[ .. ]\033[0m %s\n" "$*"; }
function echo-skip { printf "\r\033[2K\033[38;05;240m[SKIP]\033[0m %s\n" "$*"; }
function echo-ok { printf "\r\033[2K\033[0;32m[ OK ]\033[0m %s\n" "$*"; }
function echo-fail { printf "\r\033[2K\033[0;31m[FAIL]\033[0m %s\n" "$*"; }
function echo-custom { printf "\n\r\033[2K\033[0;33m[$1]\033[0m %s\n" "$2"; }
# FUNCTIONS ======================================
# Clones a git repo to the target directory
# USAGE: do-clone targetdir url name
function do-clone {
#echo-debug " Folder: $1"
#echo-debug " URL: $2"
#echo-debug " Name: $3"
if [ ! -d $1 ]; then
echo-info "Installing $3"
git clone $2 $1
echo-ok "Done"
elif [ -d $1/.git ]; then
echo-info "Updating $3"
git --work-tree=$1 --git-dir=$1/.git pull origin master
echo-ok "Done"
else
echo-skip "$3"
fi
}
# Pulls a file from curl and puts them into a specific location
# If the directory where target is does not exist, it is created
# USAGE: do-curl-fetchfile target url name
function do-curl-fetchfile {
#echo-debug " Target: $1"
#echo-debug " URL: $2"
#echo-debug " Name: $3"
if [ ! -f $1 ]; then
echo-info "Installing $3"
LOCATION=$(dirname "${1}")
mkdir -p "$LOCATION"
curl -LSso $1 $2
echo-ok "Done" else
echo-skip "$3"
fi
}
# Does a symlink between target and link_name, deleting it if it exists
# USAGE: do-symlink target link_name
function do-symlink {
#echo-debug " Target: $1"
#echo-debug " Link name: $2"
echo-info "Symlink: $2 -> $1"
# Remove link if exists
if [ -L $2 ]; then
rm $2
fi
if [ -d $2 ]; then
rm -rf $2
fi
# Create parent directory of link if necessary
mkdir -p "$(dirname "$2")"
ln -s $1 $2
}
# Sources a shell file in the given shell's rc file, if it is not there yet
# USAGE: do-source shell file
function do-source {
#echo-debug " Shell: $1"
#echo-debug " File: $2"
if [ -x "$(command -v $1)" ]; then
CONF=~/.$1rc
FILENAME=$(basename "$2")
# If file not yet sourced, source it
if ! grep -q $FILENAME $CONF
then
echo-info "$2: $CONF"
echo -e "\n# Auto source $FILENAME\nif [ -f $2 ]; then\n\tsource $2\nfi" >> $CONF
else
echo-skip "$1"
fi
fi
}
# START ===================================
#
# MAILCAP
#
echo-custom " ** " "==== MAILCAP ===="
do-symlink $DOTFILES_PATH/mailcap/.mailcap ~/.mailcap
#
# NEOVIM
#
echo-custom " ** " "==== NEOVIM ===="
do-symlink $DOTFILES_PATH/nvim $DIR_VIMCONFIG
# Create dictionary symlinks
do-symlink $DOTFILES_PATH/words/en.utf-8.dic $DIR_VIMCONFIG/spell/en.utf-8.add
#
# HELIX
#
echo-custom " ** " "==== HELIX ===="
do-symlink $DOTFILES_PATH/helix $DIR_HELIXCONFIG
#
# TMUX
#
echo-custom " ** " "==== TMUX ===="
# Install tmux resurrect
DIR_TMUXR="$DIR_PROJ/tmux-resurrect/"
if [ ! -d "$DIR_TMUXR" ]; then
mkdir -p ~/git
git clone https://github.com/tmux-plugins/tmux-resurrect $DIR_TMUXR
fi
# Create .tmux.conf symlink
rm ~/.tmux.conf
ln -s $DOTFILES_PATH/tmux/.tmux.conf ~/.tmux.conf
#
# RANGER
#
echo-custom " ** " "==== RANGER ===="
if [ ! -d "$DIR_RANGER" ]; then
mkdir -p $DIR_RANGER
fi
# Create scope.sh and rc.conf symlinks
do-symlink $DOTFILES_PATH/ranger/scope.sh $DIR_RANGER/scope.sh
do-symlink $DOTFILES_PATH/ranger/rc.conf $DIR_RANGER/rc.conf
do-symlink $DOTFILES_PATH/ranger/rifle.conf $DIR_RANGER/rifle.conf
#
# NNN
#
echo-custom " ** " "==== NNN ===="
if [ ! -d "$DIR_NNN" ]; then
mkdir -p $DIR_NNN
fi
# Create nnn config symlink
do-symlink $DOTFILES_PATH/nnn $DIR_NNN
#
# LF
#
echo-custom " ** " "==== LF ===="
# Create lf config symlink
do-symlink $DOTFILES_PATH/lf $DIR_LF
#
# YAZI
#
echo-custom " ** " "==== YAZI ===="
# Create yazi config symlink
do-symlink $DOTFILES_PATH/yazi $DIR_YAZI
#
# SCREEN
#
echo-custom " ** " "==== GNU SCREEN ===="
# Create .screenrc symlink
do-symlink $DOTFILES_PATH/screen/.screenrc ~/.screenrc
#
# zsh-autosuggestions and zsh-syntax-highlighting
#
echo-custom " ** " "==== ZSH-AUTOSUGGESTIONS ===="
do-clone "$DIR_ZSHPLUGINS"/zsh-autosuggestions https://github.com/zsh-users/zsh-autosuggestions zsh-autosuggestions
echo-custom " ** " "==== ZSH-SYNTAX-HIGHLIGHTING ===="
do-clone "$DIR_ZSHPLUGINS"/zsh-syntax-highlighting https://github.com/zsh-users/zsh-syntax-highlighting zsh-syntax-highlighting
#
# SHELL ENVIRONMENT
#
echo-custom " ** " "==== SHELL ENVIRONMENT ===="
# Source in bash and zsh
do-source "bash" $DOTFILES_PATH/env/env_global.sh
do-source "zsh" $DOTFILES_PATH/env/env_global.sh
do-source "bash" $DOTFILES_PATH/env/env_fun.sh
do-source "zsh" $DOTFILES_PATH/env/env_fun.sh
if [[ -f /etc/arch-release ]]; then
do-source "bash" $DOTFILES_PATH/env/env_arch.sh
do-source "zsh" $DOTFILES_PATH/env/env_arch.sh
fi
echo-ok "Done"
#
# FISH
#
echo-custom " ** " "==== FISH CONFIG ===="
do-symlink $DOTFILES_PATH/fish $DIR_FISH
echo-ok "Done"
#
# GIT
#
echo-custom " ** " "==== GIT CONFIG ===="
do-symlink $DOTFILES_PATH/git/.gitconfig ~/.gitconfig
echo-ok "Done"
#
# JJ
#
echo-custom " ** " "==== JJ CONFIG ===="
do-symlink $DOTFILES_PATH/jj $DIR_JJ
echo-ok "Done"
#
# i3
#
echo-custom " ** " "==== i3 CONFIG ===="
# Symlink i3 configuration
do-symlink $DOTFILES_PATH/i3 $DIR_I3
do-symlink $DOTFILES_PATH/i3blocks $DIR_I3BLOCKS
echo-ok "Done"
#
# sway
#
echo-custom " ** " "==== sway CONFIG ===="
# Symlink sway configuration
do-symlink $DOTFILES_PATH/sway $DIR_SWAY
echo-ok "Done"
#
# waybar
#
echo-custom " ** " "==== waybar CONFIG ===="
# Symlink waybar configuration
do-symlink $DOTFILES_PATH/waybar $DIR_WAYBAR
echo-ok "Done"
#
# Hyprland
#
echo-custom " ** " "==== Hyprland CONFIG ===="
# Symlink hypr configuration
do-symlink $DOTFILES_PATH/hyprland $DIR_HYPR
echo-ok "Done"
# Symlink rofi config
echo-custom " ** " "==== Rofi CONFIG ===="
do-symlink $DOTFILES_PATH/rofi $DIR_ROFI
# Symlink tschuss config
echo-custom " ** " "==== Tschuss CONFIG ===="
do-symlink $DOTFILES_PATH/tschuss $DIR_TSCHUSS
# Symlink fuzzel config
echo-custom " ** " "==== Fuzzel CONFIG ===="
do-symlink $DOTFILES_PATH/fuzzel $DIR_FUZZEL
# xkblayout
mkdir -p ~/.local/bin/
cp $DOTFILES_PATH/bin/xkblayout-state ~/.local/bin/
#
# POLYBAR
#
echo-custom " ** " "==== POLYBAR ===="
# Scripts
do-clone "$DIR_PROJ"/polybar-scripts https://github.com/x70b1/polybar-scripts.git polybar-scripts
# Config
do-symlink $DOTFILES_PATH/polybar $DIR_POLYBAR
echo-ok "Done"
#
# X, URXVT, Alacritty, Kitty
#
echo-custom " ** " "==== X, URXVT, Termite ===="
mkdir -p ~/.urxvt/ext/
# .Xdefaults and .Xresources
XRES_H=$(xwininfo -root|sed '/Height/!d;s/.* //')
XRES_W=$(xwininfo -root|sed '/Width/!d;s/.* //')
MYHOSTNAME=$(hostname)
if [[ $XRES_H -gt 1400 ]] && [[ $XRES_W -gt 2000 ]] || [[ $MYHOSTAME == "hidalgo" ]]; then
# HiDPI
echo "HiDPI detected: xres=($XRES_W,$XRES_H), host=$MYHOSTNAME"
do-symlink $DOTFILES_PATH/X/.Xresources-hidpi ~/.Xresources
do-symlink $DOTFILES_PATH/X/.Xdefaults-hidpi ~/.Xdefaults
else
# Regular
echo "Normal DPI: xres=($XRES_W,$XRES_H), host=$MYHOSTNAME"
do-symlink $DOTFILES_PATH/X/.Xdefaults ~/.Xdefaults
fi
# .xinitrc
do-symlink $DOTFILES_PATH/X/.xinitrc ~/.xinitrc
# font-size urxvt plugin
do-symlink $DOTFILES_PATH/urxvt/font-size ~/.urxvt/ext/font-size
#Kitty config
do-symlink $DOTFILES_PATH/kitty $DIR_KITTY
# Alacritty config
do-symlink $DOTFILES_PATH/alacritty $DIR_ALACRITTY
echo-ok "Done"
#
# NCMPCPP
#
echo-custom " ** " " ==== NCMPCPP ===="
do-symlink $DOTFILES_PATH/ncmpcpp $DIR_NCMPCPP
echo-ok "Done"
#
# MPD
#
echo-custom " ** " " ==== MPD ===="
do-symlink $DOTFILES_PATH/mpd/config $DIR_MPD
do-symlink $DOTFILES_PATH/mpd/playlists ~/.local/share/mpd/playlists
echo-ok "Done"
#
# xob
#
echo-custom " ** " "==== XOB ===="
do-symlink $DOTFILES_PATH/xob $DIR_XOB
echo-ok "Done"
#
# QUTEBROWSER
#
echo-custom " ** " "==== QUTEBROWSER ===="
QB_CONFIG=~/.config/qutebrowser
QB_DATA=~/.local/share/qutebrowser
# Symlink qutebrowser config
do-symlink $DOTFILES_PATH/qutebrowser/config $QB_CONFIG
# Symlink userscripts
do-symlink $DOTFILES_PATH/qutebrowser/data/userscripts $QB_DATA/userscripts
# Symlink greasemonkey js
do-symlink $DOTFILES_PATH/qutebrowser/data/greasemonkey $QB_DATA/greasemonkey
echo-ok "Done"
#
# DUNST
#
echo-custom " ** " "==== DUNST ===="
DIR_DUNST=~/.config/dunst
if [ ! -d "$DIR_DUNST" ]; then
mkdir -p $DIR_DUNST
fi
do-symlink $DOTFILES_PATH/dunst/dunstrc $DIR_DUNST/dunstrc
echo-ok "Done"
#
# MPV
#
echo-custom " ** " "==== MPV ===="
MPV_CONFIG=~/.config/mpv
do-symlink $DOTFILES_PATH/mpv $MPV_CONFIG
echo-ok "Done"
#
# MUTT
#
echo-custom " ** " "==== MUTT ===="
mkdir -p $DOTFILES_PATH/mutt/ari.uni-heidelberg.de/cache
mkdir -p $DOTFILES_PATH/mutt/tonisagrista.com/cache
do-symlink $DOTFILES_PATH/mutt $DIR_MUTT
echo-ok "Done"
#
# CLI-VISUALIZER
#
echo-custom " ** " "==== CLI-VISUALIZER ===="
do-symlink $DOTFILES_PATH/vis $DIR_VIS
echo-ok "Done"
#
# NEWSBOAT
#
echo-custom " ** " "==== NEWSBOAT ===="
do-symlink $DOTFILES_PATH/newsboat $DIR_NEWSBOAT
echo-ok "Done"
# STARSHIP SHELL
echo-custom " ** " "==== STARSHIP ===="
do-symlink $DOTFILES_PATH/starship/starship.toml $DIR_STARSHIP/starship.toml
echo-ok "Done"
# Set keyboard repeat and delay - gnome or i3 only
echo-custom " ** " "==== REPEAT DELAY 250 ms ===="
SESSION_TYPE="${DISPLAY:+x11}${WAYLAND_DISPLAY:+wayland}"
# Capture DE
if [ "$XDG_CURRENT_DESKTOP" = "" ]; then
desktop=$(echo "$XDG_DATA_DIRS" | grep -Eo 'xfce\|kde\|gnome')
else
desktop=$XDG_CURRENT_DESKTOP
fi
# Capture WM if DE is blank
if [ "$desktop" = "" ]; then
desktop=$(wmctrl -m | grep "Name:" | awk '{print $2}')
fi
desktop=${desktop,,} # convert to lower case
if [ "$desktop" = "gnome" ] && [ "$SESSION_TYPE" = "x11" ]; then
gsettings set org.gnome.desktop.peripherals.keyboard repeat-interval 20
gsettings set org.gnome.desktop.peripherals.keyboard delay 250
echo-ok "Repeat delay set for desktop: $desktop"
elif [ "$desktop" = "i3" ] && [ "$SESSION_TYPE" = "x11" ]; then
echo-ok "Repeat interval and delay for $desktop set in ~/.config/i3/config"
elif [ "$SESSION_TYPE" = "x11" ]; then
echo-fail "Not setting repeat interval for desktop: $desktop"
else
echo-fail "Not setting repeat interval for wayland"
fi
#
# FONTS
#
echo-custom " ** " "==== FONTS ===="
do-symlink $DOTFILES_PATH/fonts/ttf ~/.local/share/fonts/ttf
do-symlink $DOTFILES_PATH/fonts/otf ~/.local/share/fonts/otf
fc-cache
echo-ok "Done"
# Done
echo ""
echo-ok "Done! Your environment should be ready to go"