forked from ghaiklor/iterm-fish-fisher-osx
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall.sh
364 lines (299 loc) · 9.92 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
#!/usr/bin/env bash
#title :install.sh
#description :This script will install and configure Fish Shell + Fisherman.
#author :ghaiklor / rgaidot
#date :2020-01-22
#version :0.1
#usage :bash <(curl -s https://raw.githubusercontent.com/rgaidot/iterm-fish-fisherman-osx/master/install.sh)
#bash_version :3.2.57(1)-release
#===================================================================================
set -e
trap on_sigterm SIGKILL SIGTERM
TEMP_DIR=$(mktemp -d)
GITHUB_REPO_URL_BASE="https://github.com/rgaidot/iterm-fish-fisherman-osx/"
HOMEBREW_INSTALLER_URL="https://raw.githubusercontent.com/Homebrew/install/master/install"
COLOR_SCHEME_URL="https://raw.githubusercontent.com/MartinSeeler/iterm2-material-design/master/material-design-colors.itermcolors"
NERD_FONT_URL="https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Meslo/M-DZ/Regular/complete/Meslo%20LG%20M%20DZ%20Regular%20Nerd%20Font%20Complete%20Mono.ttf?raw=true"
FISHERMAN_URL="https://git.io/fisher"
PLUGINS_INSTALLER_URL="https://raw.githubusercontent.com/rgaidot/iterm-fish-fisherman-osx/master/install_plugins.sh"
RESET_COLOR="\033[0m"
RED_COLOR="\033[0;31m"
GREEN_COLOR="\033[0;32m"
BLUE_COLOR="\033[0;34m"
function reset_color() {
echo -e "${RESET_COLOR}\c"
}
function red_color() {
echo -e "${RED_COLOR}\c"
}
function green_color() {
echo -e "${GREEN_COLOR}\c"
}
function blue_color() {
echo -e "${BLUE_COLOR}\c"
}
function separator() {
green_color
echo "#=============================STEP FINISHED=============================#"
reset_color
}
function hello() {
green_color
echo " "
echo " _____ __ __ ____ "
echo " / __(_)____/ /_ _____/ /_ ___ / / / "
echo " / /_/ / ___/ __ \ / ___/ __ \/ _ \/ / / "
echo " / __/ (__ ) / / / (__ ) / / / __/ / / "
echo "/_/ /_/____/_/ /_/ /____/_/ /_/\___/_/_/ "
echo " "
echo " iTerm + Fish + Fisherman "
echo " by @ghaiklor "
echo " "
echo " "
blue_color
echo "This script will guide you through installing all the required dependencies for Fish Shell + Fisherman + Themes and Plugins"
echo "It will not install anything, without your direct agreement (do not afraid)"
green_color
read -p "Do you want to proceed with installation? (y/N) " -n 1 answer
echo
if [ ${answer} != "y" ]; then
exit 1
fi
reset_color
}
function install_command_line_tools() {
blue_color
echo "Trying to detect installed Command Line Tools..."
if ! [ $(xcode-select -p) ]; then
blue_color
echo "You don't have Command Line Tools installed"
echo "They are required to proceed with installation"
green_color
read -p "Do you agree to install Command Line Tools? (y/N) " -n 1 answer
echo
if [ ${answer} != "y" ]; then
exit 1
fi
blue_color
echo "Installing Command Line Tools..."
echo "Please, wait until Command Line Tools will be installed, before continue"
echo "I can't wait for its installation from the script, so continue..."
xcode-select --install
else
blue_color
echo "Seems like you have installed Command Line Tools, so skipping..."
fi
reset_color
separator
sleep 1
}
function install_homebrew() {
blue_color
echo "Trying to detect installed Homebrew..."
if ! [ $(which brew) ]; then
blue_color
echo "Seems like you don't have Homebrew installed"
echo "We need it for completing the installation of your awesome terminal environment"
green_color
read -p "Do you agree to proceed with Homebrew installation? (y/N) " -n 1 answer
echo
if [ ${answer} != "y" ]; then
exit 1
fi
blue_color
echo "Installing Homebrew..."
ruby -e "$(curl -fsSL ${HOMEBREW_INSTALLER_URL})"
brew update
brew upgrade
green_color
echo "Homebrew installed!"
else
blue_color
echo "You already have Homebrew installed, so skipping..."
fi
reset_color
separator
sleep 1
}
function install_iTerm2() {
blue_color
echo "Trying to find installed iTerm..."
if ! [ $(ls /Applications/ | grep iTerm.app) ]; then
blue_color
echo "I can't find installed iTerm"
green_color
read -p "Do you agree to install it? (y/N) " -n 1 answer
echo
if [ ${answer} != "y" ]; then
exit 1
fi
blue_color
echo "Installing iTerm2..."
brew cask install iterm2
green_color
echo "iTerm2 installed!"
else
blue_color
echo "Found installed iTerm.app, so skipping..."
fi
reset_color
separator
sleep 1
}
function install_color_scheme() {
green_color
read -p "Do you want to install color scheme for iTerm? (y/N) " -n 1 answer
echo
if [[ ${answer} == "y" || ${answer} == "Y" ]]; then
blue_color
echo "Downloading color scheme in ${TEMP_DIR}..."
cd ${TEMP_DIR}
curl -fsSL ${COLOR_SCHEME_URL} > ./material-design.itermcolors
blue_color
echo "iTerm will be opened in 5 seconds, asking to import color scheme (in case, you installed iTerm)"
echo "Close iTerm when color scheme will be imported"
sleep 5
open -W ./material-design.itermcolors
green_color
echo "Color Scheme is installed!"
else
blue_color
echo "Skipping Color Scheme installation..."
fi
reset_color
separator
sleep 1
}
function install_nerd_font() {
green_color
read -p "Do you want to install patched Nerd Fonts? (y/N) " -n 1 answer
echo
if [[ ${answer} == "y" || ${answer} == "Y" ]]; then
blue_color
echo "Downloading Nerd Font into ${TEMP_DIR}..."
cd ${TEMP_DIR}
curl -fsSL ${NERD_FONT_URL} > ./nerd_font.otf
blue_color
echo "Font Manager will be opened in 5 seconds, prompting to install Nerd Font"
echo "When you will be done with installing Nerd Font, close the Font Manager"
sleep 5
open -W ./nerd_font.otf
green_color
echo "Nerd Font is successfully installed!"
else
blue_color
echo "Skipping Nerd Font installation..."
fi
reset_color
separator
sleep 1
}
function install_fish() {
blue_color
echo "Trying to detect installed Fish Shell..."
if ! [ $(which fish) ]; then
blue_color
echo "Seems like you don't have Fish Shell installed"
echo "Fish Shell is required to continue the installation"
green_color
read -p "Do you agree to install it? (y/N) " -n 1 answer
echo
if [ ${answer} != "y" ]; then
exit 1
fi
blue_color
echo "Installing Fish Shell..."
echo "The script will ask you the password for sudo 2 times:"
echo
echo "1) When adding fish shell into /etc/shells via tee"
echo "2) When changing your default shell via chsh -s"
brew install fish
chsh -s /usr/local/bin/fish
else
blue_color
echo "You already have Fish Shell installed"
echo "Just to be sure, that this is your default shell, I'm going to call chsh..."
fi
echo "$(command -v fish)" | sudo tee -a /etc/shells
chsh -s "$(command -v fish)"
green_color
echo "Fish installed!"
reset_color
separator
sleep 1
}
function install_fisherman() {
blue_color
echo "Fisherman is required for the installation"
green_color
read -p "Do you agree to install it? (y/N) " -n 1 answer
echo
if [ ${answer} != "y" ]; then
exit 1
fi
blue_color
echo "Installing Fisherman..."
curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs ${FISHERMAN_URL}
green_color
echo "Fisherman installed!"
reset_color
separator
sleep 1
}
function install_fisherman_plugins_and_themes() {
blue_color
echo "Some of the Fisherman plugins requires external dependencies to be installed via Homebrew..."
green_color
read -p "Do you want to install Themes and Plugins for Fisherman? (y/N) " -n 1 answer
echo
if [[ ${answer} == "y" || ${answer} == "Y" ]]; then
blue_color
echo "Installing Themes and Plugins..."
cd ${TEMP_DIR}
curl -fsSL ${PLUGINS_INSTALLER_URL} > ./plugins_installer
chmod +x ./plugins_installer
./plugins_installer
green_color
echo "Themes and Plugins installed!"
else
blue_color
echo "Skipping Themes and Plugins installation..."
fi
reset_color
separator
sleep 1
}
function post_install() {
green_color
echo
echo
echo "Setup was successfully done"
echo "Do not forgot to make two simple, but manual things:"
echo
echo "1) Open iTerm -> Preferences -> Profiles -> Colors -> Presets and apply color preset"
echo "2) Open iTerm -> Preferences -> Profiles -> Text -> Font and apply font (for non-ASCII as well)"
echo
echo "Happy Coding!"
reset_color
exit 0
}
function on_sigterm() {
red_color
echo
echo -e "Wow... Something serious happened!"
echo -e "Though, I don't know what really happened :("
echo -e "Please, refer to manual installation -> ${BLUE_COLOR}${GITHUB_REPO_URL_BASE}${RED_COLOR}"
echo -e "In case, you want to help me fix this problem, raise an issue -> ${BLUE_COLOR}${GITHUB_REPO_URL_BASE}issues/new"
reset_color
exit 1
}
hello
install_command_line_tools
install_homebrew
install_iTerm2
install_color_scheme
install_nerd_font
install_fish
install_fisherman
install_fisherman_plugins_and_themes
post_install