-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·381 lines (317 loc) · 11.5 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
#!/bin/bash
#################################
######### VIMPRESSIONIST ########
#################################
set -e
echo "Coming soon..."
exit 1
# =============================
# LOG
# =============================
log() {
type="$1"
str="$2"
case "$type" in
err) echo -e "\033[0;31m$str\033[0m" 1>&2 ;;
warn) echo -e "\033[0;33m$str\033[0m" ;;
info) echo -e "\033[0;36m$str\033[0m" ;;
ok) echo -e "\033[0;32m$str\033[0m" ;;
esac
}
# =============================
# INTERACTIVE CMD
# =============================
ask() {
read -r choice
while [[ ! "$choice" =~ ^(y|n)$ ]]; do
log err "Invalid choice. Please enter 'y' (yes) or 'n' (no)."
read -r choice
done
if [ "$choice" = "n" ]; then
log ok "Bye"
exit 1
fi
}
# =============================
# DISCLAIMER
# =============================
log warn "You are going to install \033[1;33mVimpressionist\033[0m."
log warn "This will replace your configuration for each Vim-like app."
log warn "You will also need a working Internet connection.\n"
log warn "Do you really want to continue? (y/n)"
ask
# =============================
# PACKAGE MANAGEMENT
# =============================
# /!\ Be careful here!
# For instance, pacman is not a package manager on Debian systems (it is the game...).
pkg_manager=""
pkg_managers=( "pacman" "apt" "aptitude" "yum" "dnf" "zypper" "emerge" "equo" )
test_pkg() {
if hash "$1" 2> /dev/null; then
pkg_manager="$1"
fi
}
for mgr in "${pkg_managers[@]}"; do
test_pkg "$mgr"
done
pkg_update() {
# Arch & Co.
if [ "$pkg_manager" = "pacman" ] && [ -f /etc/arch-release ]; then
sudo pacman -Syu --noconfirm
# Debian & Co.
elif [ "$pkg_manager" = "apt" ] && [ -f /etc/debian_version ]; then
sudo apt-get update
sudo apt-get --assume-yes upgrade
elif [ "$pkg_manager" = "aptitude" ] && [ -f /etc/debian_version ]; then
sudo aptitude update
sudo aptitude --assume-yes upgrade
# Red Hat & Co.
elif [ "$pkg_manager" = "yum" ] && [ -f /etc/redhat-release ]; then
sudo yum update
elif [ "$pkg_manager" = "dnf" ] && [ -f /etc/redhat-release ]; then
sudo dnf update
# SuSE & Co.
elif [ "$pkg_manager" = "zypper" ] && [ -f /etc/SuSE-release ]; then
sudo zypper update
# Gentoo & Co.
# elif [ "$pkg_manager" = "emerge" ] && [ -f /etc/gentoo-release ]; then
# sudo emerge install "$@"
# elif [ "$pkg_manager" = "equo" ] && [ -f /etc/gentoo-release ]; then
# sudo equo install "$@"
else
log err "Your package manager has not been recognized."
exit 2
fi
}
pkg_install() {
# Arch & Co.
if [ "$pkg_manager" = "pacman" ] && [ -f /etc/arch-release ]; then
if [ "$#" -eq 0 ]; then
# vte3-ng is a dependency of the Termite package (conflict with vte3)
sudo pacman -Rdd --noconfirm vte3
sudo pacman -S --noconfirm i3 dmenu gvim vifm zathura zathura-pdf-mupdf termite mutt cmus feh lynx conky
else
sudo pacman -S --noconfirm "$@"
fi
# Debian & Co.
elif [ "$pkg_manager" = "apt" ] && [ -f /etc/debian_version ]; then
if [ "$#" -eq 0 ]; then
# Termite is not in official repos
git clone https://github.com/Corwind/termite-install.git
sh termite-install/termite-install.sh
sudo apt-get --assume-yes install i3 suckless-tools vim vim-gnome vifm zathura mutt cmus feh lynx conky
else
sudo apt-get --assume-yes install "$@"
fi
elif [ "$pkg_manager" = "aptitude" ] && [ -f /etc/debian_version ]; then
if [ "$#" -eq 0 ]; then
# Termite is not in official repos
git clone https://github.com/Corwind/termite-install.git
sh termite-install/termite-install.sh
sudo aptitude --assume-yes install i3 suckless-tools vim vim-gnome vifm zathura mutt cmus feh lynx conky
else
sudo aptitude --assume-yes install "$@"
fi
# Red Hat & Co.
elif [ "$pkg_manager" = "yum" ] && [ -f /etc/redhat-release ]; then
if [ "$#" -eq 0 ]; then
# Cmus and Termite are not in official repos
# Termite install???
su -lc 'yum install --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm'
sudo yum --assumeyes install i3 dmenu vim-enhanced vim-X11 vifm zathura mutt cmus feh lynx conky
else
sudo yum --assumeyes install "$@"
fi
elif [ "$pkg_manager" = "dnf" ] && [ -f /etc/redhat-release ]; then
if [ "$#" -eq 0 ]; then
# Cmus and Termite are not in official repos
su -lc 'dnf install --nogpgcheck http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm'
sudo dnf --assumeyes install i3 dmenu vim-enhanced vim-X11 vifm zathura mutt cmus feh lynx conky
else
sudo dnf --assumeyes install "$@"
fi
# SuSE & Co.
elif [ "$pkg_manager" = "zypper" ] && [ -f /etc/SuSE-release ]; then
if [ "$#" -eq 0 ]; then
# Zathura, Cmus and Termite are not in official repos
sudo zypper addrepo http://download.opensuse.org/repositories/home:msvec/openSUSE_Tumbleweed/home:msvec.repo
sudo zypper addrepo http://download.opensuse.org/repositories/home:cschneemann/openSUSE_Tumbleweed/home:cschneemann.repo
sudo zypper addrepo http://download.opensuse.org/repositories/home:cyphar/openSUSE_Tumbleweed/home:cyphar.repo
sudo zypper refresh
sudo zypper --non-interactive install i3 dmenu vim gvim vifm zathura termite mutt cmus feh lynx conky
else
sudo zypper --non-interactive install "$@"
fi
# Gentoo & Co.
# elif [ "$pkg_manager" = "emerge" ] && [ -f /etc/gentoo-release ]; then
# if [ "$#" -eq 0 ]; then
# sudo emerge install ...
# else
# sudo emerge install "$@"
# fi
# elif [ "$pkg_manager" = "equo" ] && [ -f /etc/gentoo-release ]; then
# if [ "$#" -eq 0 ]; then
# sudo emerge install ...
# else
# sudo equo install "$@"
# fi
else
log err "Your package manager has not been recognized."
exit 2
fi
}
# =============================
# DEPENDENCIES
# =============================
# Tests based on exit codes (0 = OK)
firefox=$(hash firefox 2> /dev/null; echo $?)
chromium=$(hash chromium 2> /dev/null || hash chromium-browser 2> /dev/null; echo $?)
git=$(hash git 2> /dev/null; echo $?)
if [ "$firefox" -ne 0 ]; then
log warn "Firefox is necessary to use Vimperator. Installing Firefox..."
pkg_install "firefox"
fi
if [ "$chromium" -ne 0 ]; then
log warn "Chromium is necessary to use Vimium. Installing Chromium..."
if [ "$pkg_manager" = "apt" ]; then
pkg_install "chromium-browser"
else
pkg_install "chromium"
fi
fi
if [ "$git" -ne 0 ]; then
log warn "Git is necessary to clone vim-anywhere. Installing Git..."
pkg_install "git"
fi
# =============================
# CORE
# =============================
# Main packages
pkg_install
# log warn "vim-anywhere requires GNOME desktop environment (DE)"
# log warn "Do you want to install GNOME? (y/n)"
# log warn "(If you answer 'no', you will keep your DE and vim-anywhere will not be installed.)"
# ask "optional"
# if [ "$choice" = "y" ]; then
# git clone https://github.com/cknadler/vim-anywhere.git
# pkg_install xclip
# bash vim-anywhere/install
# rm -rf vim-anywhere
# fi
log info "So far so good! Now you have to install Vimperator manually."
log info "Firefox will open a new window at the right URL."
log info "Please close it after the installation of Vimperator to continue with the wizard."
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'
firefox https://addons.mozilla.org/fr/firefox/addon/vimperator/
log info "Alright! Now you need to do the same thing for Vimium."
log info "Chromium will open a new window at the right URL."
log info "Please close it after the installation of Vimium to continue with the wizard."
read -n1 -rsp $'Press any key to continue or Ctrl+C to exit...\n'
if [ "$pkg_manager" = "apt" ]; then
chromium-browser https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
else
chromium https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
fi
cp readline/inputrc ~/.inputrc
# -----------------------------
# Handle simple directories
# -----------------------------
# Simple means that there is only one possible config directory
# So basically it exists or not...
handle_simple_dir() {
dir="$1"
if [ -d "$dir" ]; then
rm -rf "${dir:?}/*"
else
mkdir "$dir"
fi
}
# -----------------------------
# (G)Vim
# -----------------------------
# vimrc & gvimrc files are generally created by the user
# They are not created automatically after an install
handle_simple_dir ~/.vim
cp -r vim/* ~/.vim
mv ~/.vim/vimrc ~/.vimrc
# Plugins
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
vim +PluginInstall +qall
# Patched fonts
git clone https://github.com/powerline/fonts.git
bash fonts/install.sh
rm -rf fonts
# -----------------------------
# i3
# -----------------------------
# i3 comes with a config directory
# It can be ~/.config/i3 or ~/.i3
if [ -d ~/.config/i3 ]; then
rm -rf ~/.config/i3/*
cp -r i3/* ~/.config/i3
mv ~/.config/i3/conkyrc ~/.conkyrc
sudo mv ~/.config/i3/scripts/* /usr/local/bin
else
rm -rf ~/.i3/*
cp -r i3/* ~/.i3
mv ~/.i3/conkyrc ~/.conkyrc
sudo mv ~/.i3/scripts/* /usr/local/bin
fi
# -----------------------------
# Vifm
# -----------------------------
# Vifm comes with a config directory
# It can be ~/.config/vifm or ~/.vifm
if [ -d ~/.config/vifm ]; then
rm -rf ~/.config/vifm/*
cp -r vifm/* ~/.config/vifm
else
rm -rf ~/.vifm/*
cp -r vifm/* ~/.vifm
fi
# -----------------------------
# Zathura
# -----------------------------
# Zathura normally comes with an empty config directory
# Here is the path: ~/.config/zathura
handle_simple_dir ~/.config/zathura
cp -r zathura/* ~/.config/zathura
# -----------------------------
# Termite
# -----------------------------
# There is usually no Termite directory after install
handle_simple_dir ~/.config/termite
cp -r termite/* ~/.config/termite
echo -e "\n# Termite hack" >> ~/.bashrc
echo "source /etc/profile.d/vte.sh" >> ~/.bashrc
# -----------------------------
# Mutt
# -----------------------------
# Mutt does not create directories or files in $HOME after install
# The user is responsible for its entire configuration (through ~/.muttrc and ~/.mutt)
handle_simple_dir ~/.mutt
cp -r mutt/* ~/.mutt
mv ~/.mutt/muttrc ~/.muttrc
# -----------------------------
# Vimperator
# -----------------------------
# Vimperator should create its config directory (~/.vimperator) automatically
handle_simple_dir ~/.vimperator
cp -r vimperator/* ~/.vimperator
mv ~/.vimperator/vimperatorrc ~/.vimperatorrc
# -----------------------------
# Vimium
# -----------------------------
log info "Almost done! Now you have to configure Vimium manually."
log info "Check the vimiumrc in the repo and copy/paste every part of the config.\n"
if [ "$pkg_manager" = "apt" ]; then
chromium-browser chrome-extension://dbepggeogbaibhgnhhndojpepiihcmeb/pages/options.html
else
chromium chrome-extension://dbepggeogbaibhgnhhndojpepiihcmeb/pages/options.html
fi
# =============================
# END
# =============================
log ok "OK"
exit 0