-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstall.sh
executable file
·163 lines (148 loc) · 3.6 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
configs=(
".xinitrc"
".Xresources"
".Xresources.d"
".config"
".zshrc"
)
paks_pacman=(
"i3-gaps"
"cmus"
"maim"
"flameshot"
"neovim"
"rofi"
"feh"
"xss-lock"
"rxvt-unicode"
"thunar"
"ranger"
"ueberzug"
"zathura"
"dunst"
"papirus-icon-theme"
"yarn"
)
paks_yay=(
"betterlockscreen"
"breeze-default-cursor-theme"
"qogir-gtk-theme"
"candy-icons-git"
"picom-ibhagwan-git"
"cava"
"eww-git"
"lemonbar-xft-git"
"ttf-hack-nerd"
"ttf-iosevka"
)
function install_pacman() {
local paks_install=""
for i in "${paks_pacman[@]}"; do
paks_install="$paks_install$i "
done
echo -n $paks_install
if [ "$EUID" -ne 0 ]; then
sudo pacman -Sy $paks_install
else
printf "\033[31mpacman\033[39m: Already \033[36mroot\033[39m (--noconfirm)\n"
pacman -Sy $paks_install --noconfirm
fi
}
function install_aur() {
local paks_install=""
for i in "${paks_yay[@]}"; do
paks_install="$paks_install$i "
done
if [ "$EUID" -ne 0 ]; then
if [ ! command -v yay &> /dev/null ]; then
printf "\033[31myay\033[39m: no yay"
else
yay -Sy $paks_install
fi
else
printf "\033[31myay\033[39m: Already \033[36mroot\033[39m (not allowed)\n"
fi
}
function move_configs() {
for i in ${configs[@]}; do
if [ -e "./${i}" ]; then
if [ -d "./${i}" ]; then
mkdir -p "$HOME/${i}"
find "./${i}" -maxdepth 1 -mindepth 1 | {
while read line; do
save="$HOME/${i}/${line##*/}"
if [ -e "${save}" ]; then
mv "${save}" "${save}.save"
if [ $? -ne 0 ]; then
printf "\033[31m%s\033[39m: initial config not saved\n" \
"$HOME/${i}" >&2
else
printf "\033[36m%s\033[39m: initial config source \033[36m%s\033[39m saved as \033[36m%s.save\033[39m\n" \
"$HOME/${i}" "${line##*/}" "${line##*/}"
fi
fi
cp -r "./${i}/${line##*/}" "$HOME/${i}"
if [ $? -ne 0 ]; then
printf "\033[31m$HOME/${i}\033[39m: failed to add \033[36m${line##*/}\033[39m\n" >&2
else
printf "\033[36m$HOME/${i}\033[39m: added \033[36m${line##*/}\033[39m\n"
fi
done
}
else
save="$HOME/${i}"
if [ -e "${save}" ]; then
mv "${save}" "${save}.save"
if [ $? -ne 0 ]; then
printf "\033[31m%s\033[39m: initial config not saved\n" \
"$HOME" >&2
else
printf "\033[36m%s\033[39m: initial config source \033[36m%s\033[39m saved as \033[36m%s.save\033[39m\n" \
"$HOME" "${i}" "${i}"
fi
fi
cp -r "./${i}" "$HOME"
if [ $? -ne 0 ]; then
printf "\033[31m$HOME\033[39m: failed to add \033[36m${i}\033[39m\n"
else
printf "\033[36m$HOME\033[39m: added \033[36m${i}\033[39m\n"
fi
fi
else
printf "$i: \033[31minvalid path\033[39m\n"
fi
done
}
function make_nvim() {
if [ ! -e "$HOME/.local/share/nvim/site/autoload/plug.vim" ]; then
sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
fi
nvim -c 'PlugUpdate' -c 'PlugInstall' -c 'qa!'
}
function show_help() {
printf "Usage: ./install.sh [SUB-COMMAND]\n\n help\t\tshow this message\n yay\t\tinstall aur packages\n pacman\tinstall pacman packages\n nvim\t\tinstall nvim plugins\n set\t\tmove configs to home\n\nOn no sub-commands script will use default settings.\n\n"
}
if [ $# -lt 1 ]; then
install_pacman
install_aur
move_configs
make_nvim
fi
while (( "$#" )); do
arg=$1
case $arg in
pacman)
install_pacman ;;
yay)
install_aur ;;
set)
move_configs ;;
nvim)
make_nvim ;;
help)
show_help ;;
*)
printf "\033[31m%s\033[39m: No such sub-command\n" "$arg" >&2
esac
shift
done