-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·897 lines (787 loc) · 22.4 KB
/
install.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
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
#!/bin/bash
################################################################################
# Functions #
################################################################################
################################################################################
# Gets the full path to a relative path
#
# arg1: The path to be converted into absolute
# return: The full path
function fullPath {
local targetFile physDir result
targetFile="${1}"
cd `dirname "${targetFile}"`
targetFile=`basename "${targetFile}"`
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
physDir=`pwd -P`
result="${physDir}/${targetFile}"
result="${result%/.}"
echo ${result}
}
################################################################################
# Shows a prompt to confirm continuation. Aborts the script if cancelled
#
# return: Success if accepted. Will abort if cancelled
function checkContinue {
local input
if [ "${1}" ]
then
echo "[31m${1}[m"
fi
echo -n "Continue? [y/N] "
read input
case ${input} in
[Yy] ) return 0 ;;
esac
exit
}
################################################################################
# Checks and installs a package.
#
# arg1: Friendly name for the package
# arg2: Package install command
# arg3: The conditions to check if the package is installed
# return: Abort if cancelled, or success otherwise
function checkInstall {
local input
echo -n "[34mChecking ${1}.. [[m"
if eval ${3}
then
echo "[32mOK[34m][m"
else
echo "[31mFAIL[34m][m"
echo -n "Install ${1}? [Y/n] "
read input
case ${input} in
[Nn] ) ;;
*)
if eval "${2}"
then
echo "[32mDone![m"
else
checkContinue "Could not install ${1}!"
return 1
fi
;;
esac
fi
return 0
}
################################################################################
# Helper function. Since most of the calls to checkInstall are similar
# this function autogenerates the arguments
#
# arg1: Name of the package
# return: Abort if cancelled, or success otherwise
function checkInstallDefault {
local checkString='[ $(command -v '"${1}"') ]'
checkInstall ${1} "${PACKAGE_INSTALL} ${1}" "${checkString}"
}
################################################################################
# Installs a file. The installation might be a copy or a symlink
# The target file is checked for existence and a prompt will ask if it should
# be overwritten
#
# arg1: Either "s" or "c" for symlink or copy, respectively
# arg2: The source path
# [arg3]: Installation path. Defaults to $HOME.
# [arg4]: Installation file name override.
# return: Failure if cancelled, or status code of install operation
function installFile {
local installPath installName overwrite input
local source="${BASE_DIR}/${2}"
if [ ! -f "${source}" ] && [ ! -d "${source}" ]
then
echo "[31mSource path does not exist:[m ${source}"
return 1
fi
if [ "${3}" ]
then
if [ "${3:0:1}" = "/" ]
then
installPath="${3}/"
else
installPath="${HOME}/${3}/"
fi
else
installPath="${HOME}/"
fi
if [ "${4}" ]
then
installName="${4}"
else
installName=`basename "${2}"`
fi
echo "[34mInstalling ${installPath}${installName}..[m"
overwrite=false
if [ ! -d ${installPath} ]
then
echo -n "${installPath} does not exist. Create? [Y/n] "
read input
case ${input} in
[Nn] )
checkContinue
return 1
;;
* ) mkdir -p "${installPath}" ;;
esac
fi
if [ -f "${installPath}${installName}" ] || [ -d "${installPath}${installName}" ] || [ -L "${installPath}${installName}" ]
then
if [ "${1}" = "s" ] && ([ ! -L "${installPath}${installName}" ] || [ "`readlink -- "${installPath}${installName}"`" != "${source}" ])
then
echo -n "${installPath}${installName} seems to not be correctly linked. Overwrite? [Y/n] "
read input
case ${input} in
[Nn] ) ;;
* )
rm -rf "${installPath}${installName}"
overwrite=true
;;
esac
else
if [ ${NO_OVERWRITE} ]
then
echo "Already exists. Skipping.."
return 1
else
echo -n "${installPath}${installName} already exists. Overwrite? [y/N] "
read input
case ${input} in
[Yy] )
rm "${installPath}${installName}"
overwrite=true
;;
esac
fi
fi
else
overwrite=true
fi
if [[ "${overwrite}" == "true" ]]
then
if [[ "${1}" == "s" ]]
then
ln -sf "${source}" "${installPath}${installName}"
elif [[ "${1}" == "c" ]]
then
cp -r "${source}" "${installPath}${installName}"
else
return 1
fi
else
return 1
fi
}
################################################################################
# Installs a file. The installation might be a copy or a symlink
# The target file is checked for existence and a prompt will ask if it should
# be overwritten
#
# arg1: Either "s" or "c" for symlink or copy, respectively
# arg2: The source file
# arg3: Installation path. Should end with /
# return: Failure if cancelled, or status code of install operation
function installPacaur {
local input
echo -n "Install pacaur? [Y/n] "
read input
case ${input} in
[Nn] )
return 0
;;
esac
if ! checkInstallDefault git
then
return 1
fi
GIT_INSTALLED=1
${SU_DO} pacman -S base-devel fakeroot jshon expac yajl
rm -rf /tmp/dotfile_pacaur_install 2> /dev/null
mkdir /tmp/dotfile_pacaur_install
cd /tmp/dotfile_pacaur_install
if git clone https://aur.archlinux.org/cower.git
then
cd cower
gpg --recv-keys --keyserver hkp://pgp.mit.edu 1EB2638FF56C0C53
makepkg && ${SU_DO} pacman --noconfirm -U *.tar.xz
fi
cd /tmp/dotfile_pacaur_install
if ! git clone https://aur.archlinux.org/pacaur.git
then
return 1
fi
cd pacaur
if makepkg && ${SU_DO} pacman --noconfirm -U *.tar.xz
then
echo "[34mUsing pacaur[m"
PACKAGE_INSTALL="pacaur --noedit --noconfirm -S"
return 0
else
return 1
fi
}
function delete {
local input searchFlag deleteFlag
if [[ "${1}" == "file" ]]
then
searchFlag='-f'
elif [[ "${1}" == "dir" ]]
then
searchFlag='-d'
deleteFlag='-rf'
else
echo "[31mInvalid parameters for delete()[m"
return -1
fi
shift
if [ ${searchFlag} "${1}" ]
then
echo -n "Delete ${1}? [y/N] "
read input
case ${input} in
[Yy] )
rm ${deleteFlag} "${1}"
;;
esac
fi
}
################################################################################
# Script start #
################################################################################
########################################
# Variables
BASE_DIR=$(dirname $(fullPath ${0}))
SU_DO=""
SYS_TYPE=""
PACKAGE_INSTALL=""
PLUGIN_MANAGER=""
ZSH_FRAMEWORK=""
if [[ "${1}" = "-no" ]]
then
NO_OVERWRITE=1
fi
########################################
# Check OS
echo -n "[34mChecking OS.. [[m"
case `uname -v` in
*Ubuntu*) SYS_TYPE="Ubuntu";;
*FreeBSD*) SYS_TYPE="FreeBSD";;
*Darwin*) SYS_TYPE="Darwin";;
*Microsoft*) SYS_TYPE="Bash on Windows";;
*)
case `uname -a` in
*ARCH*) SYS_TYPE="Arch";;
*Android*) SYS_TYPE="Android";;
*) SYS_TYPE="";;
esac
esac
unset change
if [ -z "${SYS_TYPE}" ]
then
echo "[31mFAIL[34m][m"
change=Y
else
echo "[32m${SYS_TYPE}[34m][m"
if [ -z ${NO_OVERWRITE} ]
then
echo -n "Choose a different OS? [y/N] "
read change
fi
fi
case ${change} in
[Yy] )
echo "[33mSelect your OS[m"
echo "[[33mU[m]buntu"
echo "[[33mF[m]ree BSD"
echo "[[33mD[m]arwin"
echo "A[[33mn[m]droid"
echo "[[33mB[m]ash on Windows"
echo "[[33mA[m]rch"
echo "[[33mE[m]xit"
echo -n "Choice: "
read input
case "${input}" in
[Uu]) SYS_TYPE="Ubuntu";;
[Ff]) SYS_TYPE="FreeBSD";;
[Dd]) SYS_TYPE="Darwin";;
[Nn]) SYS_TYPE="Android";;
[Bb]) SYS_TYPE="Bash on Windows";;
[Aa]) SYS_TYPE="Arch";;
*) exit;;
esac
esac
########################################
# Check sudo
if [ ! "${SYS_TYPE}" = "Android" ]
then
case `id -u` in
0) SU_DO="";;
*)
if [ ! $(command -v sudo) ]
then
checkContinue "sudo not found"
else
SU_DO="sudo"
fi
;;
esac
fi
########################################
# Determine package manager
echo -n "[34mChecking package manager.. [[m"
if [ $(command -v apt-get) ]
then
echo "[32mapt-get[34m][m"
if [ ! "${SYS_TYPE}" = "Ubuntu" ] \
&& [ ! "${SYS_TYPE}" = "Bash on Windows" ] \
&& [ ! "${SYS_TYPE}" = "Android" ]
then
checkContinue "OS mismatch"
fi
PACKAGE_INSTALL="${SU_DO} apt-get -y install"
elif [ $(command -v pkg) ]
then
echo "[32mpkg[34m][m"
[ ! "${SYS_TYPE}" = "FreeBSD" ] && checkContinue "OS mismatch"
PACKAGE_INSTALL="${SU_DO} pkg install -y"
elif [ $(command -v brew) ]
then
echo "[32mbrew[34m][m"
[ ! "${SYS_TYPE}" = "Darwin" ] && checkContinue "OS mismatch"
PACKAGE_INSTALL="brew install"
elif [ $(command -v pacaur) ]
then
echo "[32mpacaur[34m][m"
[ ! "${SYS_TYPE}" = "Arch" ] && checkContinue "OS mismatch"
PACKAGE_INSTALL="pacaur --noedit --noconfirm -S"
elif [ $(command -v pacman) ]
then
echo "[32mpacman[34m][m"
[ ! "${SYS_TYPE}" = "Arch" ] && checkContinue "OS mismatch"
PACKAGE_INSTALL="${SU_DO} pacman --noconfirm -S"
else
echo "[31mFAIL[34m][m"
echo "[31mCould not determine package manager[m"
exit
fi
########################################
# Suggest pacaur
if [[ "${PACKAGE_INSTALL}" == "${SU_DO} pacman --noconfirm -S" ]] && ! installPacaur
then
echo "[31mCould not install pacaur![m"
echo -n "Continue using pacman? [Y/n] "
read input
case ${input} in
[Nn] )
exit
;;
esac
fi
cd ${HOME}
########################################
# Install git
[ -z ${GIT_INSTALLED} ] && checkInstallDefault git
########################################
# Install curl
checkInstallDefault curl
########################################
# Install NeoVim
checkInstall "NeoVim" "${PACKAGE_INSTALL} neovim" '[ $(command -v 'nvim') ]'
########################################
# Check pluginManager
echo -n "[34mChecking Plugin Manager.. [[m"
if [ -f "${HOME}/.config/m-lima/zsh/local.zsh" ]
then
PLUGIN_MANAGER=`awk '{ if ($1 ~ /^local_pluginManager=.+/) { print $1 }}' "${HOME}/.config/m-lima/zsh/local.zsh" | cut -d '=' -f2 | tail -1`
unset change
if [ -z "${PLUGIN_MANAGER}" ]
then
PLUGIN_MANAGER=`awk '{ if ($1 ~ /^local_pluginManager=.+/) { print $1 }}' "${HOME}/.zshrc" | cut -d '=' -f2 | tail -1`
fi
if [ -z "${PLUGIN_MANAGER}" ]
then
echo "[31mFAIL[34m][m"
change=Y
else
echo "[32m${PLUGIN_MANAGER}[34m][m"
if [ -z ${NO_OVERWRITE} ]
then
echo -n "Choose a different manager? [y/N] "
oldPluginManager="${PLUGIN_MANAGER}"
read change
fi
fi
case ${change} in
[Yy] )
echo "[33mSelect your manager[m"
echo "Z[[33mG[m]en"
echo "Z[[33mP[m]lug"
echo "[[33mN[m]one"
echo "[[33mE[m]xit"
echo -n "Choice: "
read input
case "${input}" in
[Gg]) PLUGIN_MANAGER="zgen";;
[Pp]) PLUGIN_MANAGER="zplug";;
[Nn]) PLUGIN_MANAGER="";;
*) exit;;
esac
echo -n "Updating local configuration"
if sed -i 's~pluginManager=.*~pluginManager='"${PLUGIN_MANAGER}"'~g' "${HOME}/.config/m-lima/zsh/local.zsh"
then
echo " by replacing existing declaration"
else
echo " by inserting new declaration"
echo 'pluginManager='"${PLUGIN_MANAGER}" >> "${HOME}/.config/m-lima/zsh/local.zsh"
fi
esac
fi
########################################
# Check ZSH framework
echo -n "[34mChecking ZSH framework.. [[m"
if [ -f "${HOME}/.config/m-lima/zsh/local.zsh" ]
then
ZSH_FRAMEWORK=`awk '{ if ($1 ~ /^local_zshFramework=.+/) { print $1 }}' "${HOME}/.config/m-lima/zsh/local.zsh" | cut -d '=' -f2 | tail -1`
unset change
if [ -z "${ZSH_FRAMEWORK}" ]
then
ZSH_FRAMEWORK=`awk '{ if ($1 ~ /^local_zshFramework=.+/) { print $1 }}' "${HOME}/.zshrc" | cut -d '=' -f2 | tail -1`
fi
if [ -z "${ZSH_FRAMEWORK}" ]
then
echo "[31mFAIL[34m][m"
change=Y
else
oldZshFramework="${ZSH_FRAMEWORK}"
echo "[32m${ZSH_FRAMEWORK}[34m][m"
if [ -z ${NO_OVERWRITE} ]
then
echo -n "Choose a different framework? [y/N] "
read change
fi
fi
case ${change} in
[Yy] )
echo "[33mSelect your framework[m"
echo "[[33mP[m]rezto"
echo "[[33mO[m]h-my-zsh"
echo "[[33mN[m]one"
echo "[[33mE[m]xit"
echo -n "Choice: "
read input
case "${input}" in
[Pp]) ZSH_FRAMEWORK="prezto";;
[Oo]) ZSH_FRAMEWORK="omz";;
[Nn]) ZSH_FRAMEWORK="";;
*) exit;;
esac
echo -n "Updating local configuration"
if sed -i 's~zshFramework=.*~zshFramework='"${ZSH_FRAMEWORK}"'~g' "${HOME}/.config/m-lima/zsh/local.zsh"
then
echo " by replacing existing declaration"
else
echo " by inserting new declaration"
echo 'zshFramework='"${ZSH_FRAMEWORK}" >> "${HOME}/.config/m-lima/zsh/local.zsh"
fi
esac
fi
########################################
# Install vim
if [[ "${SYS_TYPE}" == "Darwin" ]]
then
checkInstall "Vim" "${PACKAGE_INSTALL} vim --with-lua" '[ $(command -v 'vim') ]'
elif [[ "${SYS_TYPE}" == "Arch" ]]
then
checkInstall "Vim" "${PACKAGE_INSTALL} vim" '[ $(command -v 'vim') ]'
else
checkInstall "Vim" "${PACKAGE_INSTALL} vim-nox" '[ $(command -v 'vim') ]'
fi
########################################
# Install Vim-Plug
# checkInstall "Vundle" 'git clone https://github.com/VundleVim/Vundle.vim.git "${HOME}"/.vim/bundle/Vundle.vim' '[ -d "${HOME}"/.vim/bundle/Vundle.vim ]'
# NeoVim
if [ $(command -v nvim) ]
then
if checkInstall "Vim-Plug for NeoVim" 'curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' '[ -f ~/.local/share/nvim/site/autoload/plug.vim ]'
then
nvim -c 'PlugInstall' -c 'qa!'
fi
else
echo "[33mSkipping Vim-Plug for NeoVim[m"
fi
# Vim
if [ $(command -v vim) ]
then
if checkInstall "Vim-Plug for Vim" 'curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' '[ -f ~/.vim/autoload/plug.vim ]'
then
vim -c 'PlugInstall' -c 'qa!'
fi
else
echo "[33mSkipping Vim-Plug for Vim[m"
fi
########################################
# Install tmux
checkInstallDefault tmux
########################################
# Install ZSH
if checkInstallDefault zsh && [ ! "${SYS_TYPE}" = "Bash on Windows" ]
then
echo -n "[34mChecking default shell.. [[m"
if [[ "${SHELL}" == */zsh ]]
then
echo "[32mOK[34m][m"
else
echo "[31mFAIL[34m][m"
echo -n "Set ZSH as main shell? [y/N] "
read input
case ${input} in
[Yy] )
echo "[34mSetting as main shell..[m"
if chsh -s $(which zsh)
then
echo "[32mDone![m"
export SHELL=zsh
else
checkContinue "Could not set the main shell!"
fi
;;
esac
fi
fi
########################################
# Install bat
checkInstall "Bat" "${PACKAGE_INSTALL} bat" '[ $(command -v "bat") ] || [ $(command -v "batcat") ]'
########################################
# Install delta
if [ "${SYS_TYPE}" = "Ubuntu" ]
then
echo '[33mIncompatible OS for delta[m check https://dandavison.github.io/delta/installation.html for manual installation'
else
checkInstall "Delta" "${PACKAGE_INSTALL} git-delta" '[ $(command -v "delta") ]'
fi
########################################
# Install fzf
checkInstall "fzf" 'git clone --depth 1 https://github.com/junegunn/fzf.git ${HOME}/code/others/fzf && "${HOME}/code/others/fzf/install" --no-fish' '[ $(command -v "fzf") ]'
########################################
# Install rg
checkInstall "rg" "${PACKAGE_INSTALL} ripgrep" '[ $(command -v "rg") ]'
########################################
# Create ~/bin
echo -n "[34mChecking bin folder.. [[m"
if [ -d "${HOME}"/bin ]
then
echo "[32mOK[34m][m"
else
echo "[31mFAIL[34m][m"
echo "[34mCreating folder..[m"
if mkdir "${HOME}"/bin &> /dev/null
then
echo "[32mDone![m"
else
checkContinue "Could not create bin folder!"
fi
fi
########################################
# Make symlinks
echo "[33mMaking symlinks..[m"
if [ $(command -v zsh) ]
then
installFile s zsh/.zshrc
installFile s zsh/.zshenv
installFile s zsh/config .config/m-lima zsh
else
echo "[33mSkipping ZSH links[m"
fi
if [ $(command -v git) ]
then
installFile s git/.gitconfig
if installFile s git/config .config/m-lima git
then
touch "${HOME}/.config/m-lima/git/local"
vi "${HOME}/.config/m-lima/git/local"
fi
else
echo "[33mSkipping Git links[m"
fi
if [ $(command -v nvim) ] || [ $(command -v vim) ]
then
installFile s vim/config .config/m-lima vim
else
echo "[33mSkipping generic (Neo)Vim links[m"
fi
if [ $(command -v nvim) ]
then
installFile s vim/init.vim .config/nvim
installFile s vim/grayalt.vim .config/nvim/colors
installFile s vim/simpalt.vim .config/nvim/colors
installFile s vim/config/lua .config/nvim
else
echo "[33mSkipping NeoVim links[m"
fi
if [ $(command -v vim) ]
then
installFile s vim/init.vim . .vimrc
installFile s vim/grayalt.vim .vim/colors
installFile s vim/simpalt.vim .vim/colors
else
echo "[33mSkipping Vim links[m"
fi
if [ $(command -v nvim) ] || [ $(command -v vim) ]
then
installFile s vim/.ideavimrc .
else
echo "[33mSkipping IdeaVim links[m"
fi
if [ $(command -v tmux) ]
then
if installFile s tmux .config tmux
then
touch "${HOME}/.config/tmux/local.conf"
vi "${HOME}/.config/tmux/local.conf"
fi
else
echo "[33mSkipping Tmux links[m"
fi
if [ $(command -v alacritty) ]
then
if installFile s alacritty/config .config alacritty
then
case "${SYS_TYPE}" in
Darwin)
ln -sf macos.yml "${HOME}/.config/alacritty/system.yml" ;;
*)
ln -sf linux.yml "${HOME}/.config/alacritty/system.yml" ;;
esac
fi
fi
installFile s scripts/scaffpp bin
installFile s scripts/scaffjs bin
installFile s scripts/cargo-all bin
installFile s scripts/rg-comment bin
installFile s scripts/rpl bin
if [[ "${SYS_TYPE}" == "Android" ]]
then
installFile s termux/colors.properties .termux
fi
if [ $(command -v bat) ]
then
installFile s config/bat/config `bat --config-dir`
elif [ $(command -v batcat) ]
then
installFile s config/bat/config `batcat --config-dir`
fi
if [ $(command -v cargo) ]
then
if [ -n "${CARGO_HOME}" ]
then
installFile s cargo/config.toml "${CARGO_HOME}"
else
installFile s cargo/config.toml "${HOME}/.cargo"
fi
fi
########################################
# Copy files
echo "[33mCopying files..[m"
if [ $(command -v zsh) ]
then
if installFile c zsh/local.zsh .config/m-lima/zsh
then
if [[ "${PACKAGE_INSTALL}" == "pacaur --noedit --noconfirm -S" ]]
then
echo "alias pc='pacaur --color always'" >> "${HOME}/.config/m-lima/zsh/local.zsh"
echo "alias pcm='pacman --color always'" >> "${HOME}/.config/m-lima/zsh/local.zsh"
fi
[ "${PLUGIN_MANAGER}" ] && echo "pluginManager=${PLUGIN_MANAGER}" >> "${HOME}/.config/m-lima/zsh/local.zsh"
[ "${ZSH_FRAMEWORK}" ] && echo "zshFramework=${ZSH_FRAMEWORK}" >> "${HOME}/.config/m-lima/zsh/local.zsh"
vi "${HOME}/.config/m-lima/zsh/local.zsh"
fi
if installFile c zsh/final.zsh .config/m-lima/zsh
then
vi "${HOME}/.config/m-lima/zsh/final.zsh"
fi
if installFile c config/fd/config .config/m-lima/fd
then
vi "${HOME}/.config/m-lima/fd/config"
fi
else
echo "[33mSkipping ZSH files[m"
fi
########################################
# PyEnv for (Neo)Vim
if [ $(command -v nvim) ]
then
if [ ! -d "${HOME}/code/python/env/vim" ] || [ -z ${NO_OVERWRITE} ]
then
echo "[34mInstalling vim pyenv..[m"
echo -n "Create pyenv for vim? [y/N] "
read input
case ${input} in
[Yy] )
python3 -m virtualenv &> /dev/null
if (( $? == 2 ))
then
python3 -m virtualenv "${HOME}/code/python/env/vim"
else
python3 -m venv &> /dev/null
if (( $? == 2 ))
then
python3 -m venv "${HOME}/code/python/env/vim"
fi
fi
if [ -f "${HOME}/code/python/env/vim/bin/activate" ]
then
source "${HOME}/code/python/env/vim/bin/activate"
pip3 install pynvim
deactivate
else
echo "[31mCould not set virtual environment[m"
fi
esac
fi
fi
########################################
# Download fonts
echo "[33mDownloading fonts..[m"
echo -n "Download fonts? [y/N] "
read input
case ${input} in
[Yy] )
if [ ! -f "${HOME}/DejaVu Sans Mono for Powerline.ttf" ] || [ -z ${NO_OVERWRITE} ]
then
echo "[34mDownloading font..[m"
echo -n "Download DejaVu Sans for Powerline? [y/N] "
read input
case ${input} in
[Yy] )
cd "${HOME}"
curl -s -L 'https://raw.githubusercontent.com/powerline/fonts/master/DejaVuSansMono/DejaVu Sans Mono for Powerline.ttf' -o "${HOME}/DejaVu Sans Mono for Powerline.ttf" && echo "[32mFont saved as ${HOME}/DejaVu Sans Mono for Powerline.ttf[m"
;;
esac
fi
if [ ! -f "${HOME}/DejaVu Sans Mono Nerd Font.zip" ] || [ -z ${NO_OVERWRITE} ]
then
echo -n "Download DejaVu Sans Nerd Font? [y/N] "
read input
case ${input} in
[Yy] )
cd "${HOME}"
curl -s -L 'https://github.com/ryanoasis/nerd-fonts/releases/download/v2.0.0/DejaVuSansMono.zip' -o "${HOME}/DejaVu Sans Mono Nerd Font.zip" && echo "[32mFont saved as ${HOME}/DejaVu Sans Mono Nerd Font.zip[m"
;;
esac
fi
if [ ! -f "${HOME}/ter-powerline-v14b.psf.gz" ] || [ -z ${NO_OVERWRITE} ]
then
echo "[34mDownloading font..[m"
echo -n "Download Terminus Powerline PSF? [y/N] "
read input
case ${input} in
[Yy] )
cd "${HOME}"
curl -s -L 'https://github.com/ryanoasis/nerd-fonts/raw/master/src/unpatched-fonts/Terminus/PSF/ter-powerline-v14b.psf.gz' -o "${HOME}/ter-powerline-v14b.psf.gz" && echo "[32mFont saved as ${HOME}/ter-powerline-v14b.psf.gz[m"
;;
esac
fi
;;
esac