-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
install
executable file
·252 lines (217 loc) · 6.18 KB
/
install
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
#!/usr/bin/env sh
set -o errexit -o nounset
WORKDIR="$HOME"
PV="3.2.1"
###############################################################
# Check deps
if ! hash git 2>/dev/null ; then
echo "You have to install git plz"
exit 1
fi
###############################################################
# Local functions
die() { echo "[-] $1"; exit 1; }
anim() {
while :; do
printf "%s\b" '/'
sleep 0.1
printf "%s\b" '-'
sleep 0.1
printf "%s\b" '\'
sleep 0.1
printf "%s\b" '|'
sleep 0.1
done
}
# Download with git ( arg1 = url | arg2 = path )
dl() {
printf "%s " "dll $1..."
anim &
pid="$!"
git clone "$1" "$2" 2>/dev/null || exit 1
printf "%s\n" "[Ok]"
# Kill anim()
kill -9 "$pid"
}
# Check if file exist else download ( arg1 = url | arg2 = path )
chk() {
[ -d "$2" ] || dl "$1" "$2"
}
forZsh() {
OH_MY_ZSH="$WORKDIR"/.oh-my-zsh
ZSH_PLUGINS="$WORKDIR/.oh-my-zsh/custom/plugins"
[ -d "$ZSH_PLUGINS/zsh-autosuggestion" ] && rm -rf "$ZSH_PLUGINS/zsh-autosuggestion"
[ -d "$ZSH_PLUGINS/zsh-syntax-highlighting" ] && rm -rf "$ZSH_PLUGINS/zsh-syntax-highlighting"
[ -d "$OH_MY_ZSH" ] && {
read -p "Clearing previous ohmyzsh and updates? [y/N] "
if [[ "$REPLY" =~ ^y|^Y ]] ; then
rm -rf "$OH_MY_ZSH"
else
echo "Ok, we keep your directory..."
fi
}
chk https://github.com/ohmyzsh/ohmyzsh "$OH_MY_ZSH"
chk https://github.com/zsh-users/zsh-autosuggestions "$ZSH_PLUGINS/zsh-autosuggestions"
chk https://github.com/zsh-users/zsh-syntax-highlighting.git "$ZSH_PLUGINS/zsh-syntax-highlighting"
}
download_images() {
DEST="$WORKDIR"/images
if ! hash unzip 2>/dev/null ; then
die "You need to install unzip"
fi
[ -d "$DEST" ] || mkdir -p "$DEST"
(cd "$WORKDIR" \
&& curl -L -o walls.zip https://github.com/szorfein/walls/archive/main.zip \
&& unzip -o -j walls.zip -d "$DEST" \
&& rm -f walls.zip
)
}
install_font() {
[ -f "$2" ] || {
echo "Installing $1"
[ -d "$1" ] || mkdir -p "$1"
curl -# -L -o "$2" "$3" \
&& unzip -o -j "$2" -d "$1" \
&& rm -f "$2"
}
}
grab_fonts() {
DIR_FONT="$WORKDIR"/.local/share/fonts
[ -d "$DIR_FONT" ] || mkdir -p "$DIR_FONT"
(cd "$DIR_FONT" \
&& install_font "iosevka" "Iosevka-$PV.zip" "https://github.com/ryanoasis/nerd-fonts/releases/download/v$PV/Iosevka.zip" \
&& install_font "iosevka-term" "IosevkaTerm-$PV.zip" "https://github.com/ryanoasis/nerd-fonts/releases/download/v$PV/IosevkaTerm.zip" \
&& install_font "spacemono" "SpaceMono-$PV.zip" "https://github.com/ryanoasis/nerd-fonts/releases/download/v$PV/SpaceMono.zip" \
&& install_font cyberpunk "cyberpunk.zip" "https://dl.dafont.com/dl/?f=cyberpunks"
)
echo "Installing Material font..."
(cd "$DIR_FONT" \
&& rm -rf font-material* \
&& rm -rf MaterialDesign* \
&& rm -rf materialdesign* \
&& curl -s -L -o font-material.zip "https://github.com/Templarian/MaterialDesign-Font/archive/master.zip" \
&& unzip -q font-material.zip \
&& rm -f MaterialDesign-Font-master/{README.md,LICENSE}
)
fc-cache -vf $DIR_FONT
}
vim_clone() {
target_name="${1##*/}"
if [ -d "${DEST}/${target_name}" ] ; then
(cd "${DEST}/${target_name}" && git pull)
else
git clone "https://github.com/${1}" "${DEST}/${target_name}"
fi
}
vim() {
DEST="$WORKDIR/.vim/pack/dotfiles/start"
[ -d "$DEST" ] || mkdir -p "$DEST"
vim_clone "edkolev/tmuxline.vim"
vim_clone "dense-analysis/ale"
vim_clone "ryanoasis/vim-devicons"
vim_clone "lilydjwg/colorizer"
vim_clone "Yggdroot/indentLine"
vim_clone "mengelbrecht/lightline-bufferline"
vim_clone "airblade/vim-gitgutter"
vim_clone "christoomey/vim-tmux-navigator"
vim_clone "itchyny/lightline.vim"
vim_clone "itchyny/vim-gitbranch"
vim_clone "preservim/nerdtree"
vim_clone "szorfein/ombre.vim"
vim_clone "szorfein/vamp.vim"
}
vifm() {
[ -d "$WORKDIR/bin" ] || mkdir -p "$WORKDIR/bin"
curl -o "$WORKDIR/bin/vifmimg" -sSlL https://raw.githubusercontent.com/thimc/vifmimg/refs/heads/master/vifmimg
curl -o "$WORKDIR/bin/vifmrun" -sSlL https://raw.githubusercontent.com/thimc/vifmimg/refs/heads/master/vifmrun
curl -o "$WORKDIR/bin/fontpreview" -sSlL https://raw.githubusercontent.com/sdushantha/fontpreview/refs/heads/master/fontpreview
chmod u+x "$WORKDIR/bin/vifmimg" "$WORKDIR/bin/vifmrun" "$WORKDIR/bin/fontpreview"
printf "\nInstall of vifm done.\n\n"
}
banner() {
printf "%s\n" \
'
@@@@@@@ @@@@@@ @@@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@
@@! @@@ @@! @@@ @@! @@! @@! @@! @@! !@@
@!@ !@! @!@ !@! @!! @!!!:! !!@ @!! @!!!:! !@@!!
!!: !!! !!: !!! !!: !!: !!: !!: !!: !:!
:: : : : :. : : : : : ::.: : : :: ::: ::.: :
'
}
usage() {
printf "%s\n" \
"-z, --zsh Download and install dependencies of zsh"
printf "%s\n" \
"-i, --images Download all the wallpapers."
printf "%s\n" \
"-v, --vim Download and install vim.plug"
printf "%s\n" \
"-m, --vifm Download and install vifm dependencies."
printf "%s\n" \
"-f, --fonts Download and install all the fonts"
printf "%s\n" \
"-d, --dest Use a directory different than $HOME"
printf "%s\n" \
"-h, --help Display this help"
}
###############################################################
# Command line options
if [ "$#" -eq 0 ]; then
printf "%s\\n" "$0: Argument required"
printf "%s\\n" "Try '$0 --help' for more information."
exit 1
fi
# Options
ZSH=false
VIM=false
VIFM=false
IMG=false
FONT=false
while [ "$#" -gt 0 ] ; do
case "$1" in
-d | --dest)
WORKDIR="$2"
shift
shift
;;
-z | --zsh)
ZSH=true
shift
;;
-v | --vim)
VIM=true
shift
;;
-m | --vifm)
VIFM=true
shift
;;
-i | --images)
IMG=true
shift
;;
-f | --fonts)
FONT=true
shift
;;
-h | --help)
usage
exit 0
;;
*)
usage
printf "\\n%s\\n" "$0: Invalid option '$1'"
exit 1
;;
esac
done
main() {
banner
"$ZSH" && forZsh
"$VIM" && vim
"$VIFM" && vifm
"$IMG" && download_images
"$FONT" && grab_fonts
echo "[+] Bye"
}
main "$@"