-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunix_shell_plugins_setup.sh
executable file
·672 lines (584 loc) · 24.9 KB
/
unix_shell_plugins_setup.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
#!/usr/bin/env zsh
## global variables
## save user's current working directory
export last_working_directory="$PWD"
export ZSH="$HOME/.oh-my-zsh/"
export OSH="$HOME/.oh-my-bash/"
export OMF_PATH="$HOME/.local/share/omf/"
export OMF_CONFIG="$HOME/.config/omf/"
function main() {
## same as main() function in C language
## go to user home directory for default setup.
cd "$HOME"
## write global variables to zshrc
if [ -e "$(which git)" ]; then
## greetings
printf " \n Welcome. This script could help you with setting up some awesome plugins for bash, zsh, and fish shell. \n For more information please visit homepage. \n \n https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup \n \n"
else
printf " \n We could not find git executable file. \n Please install git by package manager i.e. Homebrew. \n"
exit 1
fi
## install oh-my-zsh firstly before other plugins. ohmyzsh overwrites zshrc. start
# ohmyzsh setup. start.
printf " \n ohmyzsh/ohmyzsh is a delightful community-driven framework for managing your zsh configuration. \n Includes 300+ optional plugins,140+ themes. \n\n Would you like to install ohmyzsh/ohmyzsh ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
ohmyzsh_setup
else
#echo No
printf " \n Skipped ohmyzsh/ohmyzsh installation. \n"
fi
# ohmyzsh setup. ENd.
## zsh-plugins setup. start.
printf " \n zsh plugins make shell look pretty and help you work easier. \n \n Would you like to install zsh plugins ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
zsh-plugins-setup
else
#echo No
printf " \n Skipped zsh plugins installation. \n"
fi
## zsh-plugins setup. End.
# oh-my-bash setup . Start.
printf " \n ohmybash/oh-my-bash is a delightful community-driven framework for managing your bash configuration. \n \n Would you like to install ohmybash/oh-my-bash ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
oh-my-bash-setup
else
#echo No
printf " \n Skipped ohmybash/oh-my-bash installation. \n"
fi
## oh-my-bash setup. End.
## ble.sh setup. start.
printf " \n akinomyoga/ble.sh is a full-featured line editor. \n Syntax highlighting, auto suggestions, vim modes, etc. \n are available in Bash interactive sessions. \n \n Would you like to install akinomyoga/ble.sh ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
ble-sh-setup
else
#echo No
printf " \n Skipped akinomyoga/ble.sh installation. \n"
fi
## ble.sh setup. End.
## oh-my-fish setup. start.
printf " \n oh-my-fish/oh-my-fish provides core infrastructure to allow you to install packages \n which extend or modify the look of your shell. \n It's fast, extensible and easy to use. \n \n Would you like to install oh-my-fish/oh-my-fish ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
oh-my-fish-setup
else
#echo No
printf " \n Skipped oh-my-fish/oh-my-fish installation. \n"
fi
# oh-my-fish setup. End.
## fish plugins setup. start.
printf " \n fish plugins extend or modify the look of your shell. \n \n Would you like to install fish plugins? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
fish_plugins_setup
else
#echo No
printf " \n Skipped fish shell plugins installation. \n"
fi
# fish plugins setup. End.
## bashhub.com setup. start.
printf " \n rcaloras/bashhub-client is Bash history in the cloud. Indexed and searchable. \n If you prefer open source self-hosted private server, here we go. \n \n https://github.com/nicksherron/bashhub-server \n \n Would you like to install rcaloras/bashhub-client ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
bashhub-client-setup
else
#echo No
printf " \n Skipped rcaloras/bashhub-client installation. \n"
fi
## bashhub.com setup. End.
## fzf setup. start.
printf " \n junegunn/fzf is an interactive Unix filter for command-line that can be used with \n any list; files, command history, processes, hostnames, bookmarks, git commits, etc. \n\n Would you like to install junegunn/fzf ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
fzf-setup
else
#echo No
printf " \n Skipped junegunn/fzf installation. \n"
fi
# fzf setup. End.
## thefuck setup. start.
printf " \n nvbn/thefuck is a magnificent app which corrects your previous console command. \n \n Would you like to install nvbn/thefuck ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
thefuck_setup
else
printf " \n Skipped thefuck setup. \n"
fi
## thefuck setup. End.
## rupa/z setup. start.
printf "rupa/z tracks your most used directories, based on 'frecency'. \n NOTE: rupa_z should be at the end of .zshrc. \n \n Would you like to install rupa/z for bash and zsh ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
rupa_z_setup
else
#echo No
printf " \n Skipped rupa/z for bash and zsh installation. \n"
fi
## rupa/z setup. End.
## clean up before exiting this script.
exiting_cleanup
}
function rupa_z_setup() {
printf " \n Setting up rupa/z for bash and zsh \n"
git clone --depth=1 https://github.com/rupa/z.git ~/Git/z/
printf " \n \n source ~/Git/z/z.sh \n \n" >>~/.zshrc
## save z.sh to another file.
# cat ~/zsh-snap/z/z.sh >>~/.zshrc
# printf " \n \n" >>~/.zshrc
printf " \n \n source ~/Git/z/z.sh \n \n" >>~/.bashrc
# cat ~/zsh-snap/z/z.sh >>~/.bashrc
# printf " \n \n" >>~/.bashrc
printf " \n rupa/z for bash and zsh was installed. \n"
}
function fish_plugins_setup() {
## fisher_installation start
printf " \n Setting up jorgebucaran/fisher . \n"
## if [ "$(which fish)"=1 ]
## prerious if statement failed.
if [ -e "$(which fish)" ]; then
## fisher official installer start
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/fish_plugins/fisher_installation.fish
fish ./fisher_installation.fish
## call rm in script itself
## rm ./fisher
## rm ./fisher_installation.fish
printf " \n jorgebucaran/fisher was installed. \n"
else
printf " \n We could not find fish shell executable file. \n Please install fish shell by package manager i.e. Homebrew. \n"
fi
## fisher_installation end
## jorgebucaran/autopair.fish setup start
printf " \n jorgebucaran/autopair.fish automatically insert, erase, and skip matching pairs(brackets) as you type in fish. \n \n Would you like to install jorgebucaran/autopair.fish ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
autopair_fish_setup
else
#echo No
printf " \n Skipped jorgebucaran/autopair.fish installation. \n"
fi
## jorgebucaran/autopair.fish setup end
## jethrokuan/z setup start
printf " \n jethrokuan/z tracks the directories you visit. \n With a combination of frequency and recency, \n it enables you to jump to the directory in mind. \n \n Would you like to install jethrokuan/z for fish ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
jethrokuan_z_setup
else
#echo No
printf " \n Skipped jethrokuan/z for fish installation. \n"
fi
## jethrokuan/z setup end
}
function jethrokuan_z_setup() {
printf " \n Setting up jethrokuan/z \n"
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/fish_plugins/z_installation.fish
fish ./z_installation.fish
rm ./z_installation.fish
printf " \n jethrokuan/z was installed. \n"
}
function autopair_fish_setup() {
printf " \n Setting up jorgebucaran/autopair.fish \n"
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/fish_plugins/autopair_installation.fish
fish ./autopair_installation.fish
rm ./autopair_installation.fish
printf " \n jorgebucaran/autopair.fish was installed. \n"
}
function thefuck_setup() {
if [ -e "$(which pip)" ]; then
printf " \n Setting up nvbn/thefuck . \n"
pip install thefuck
printf " \n nvbn/thefuck was installed. \n"
else
printf " \n We could not find pip executable file. \n Please install pip by package manager i.e. Homebrew. \n"
fi
}
function bashhub-client-setup() {
if [ -e "$(which python)" ]; then
printf " \n Setting up rcaloras/bashhub-client . \n"
curl -ksSLO https://bashhub.com/setup
printf " \n exit " >>./setup
zsh ./setup
rm ./setup
printf " \n rcaloras/bashhub-client was installed. \n"
else
printf " \n We could not find python executable file. \n Please install python by package manager i.e. Homebrew. \n"
fi
}
function fzf-ripgrep-bat-vscode-integration-setup() {
if [ -e "$(which rg)" ]; then
if [ -e "$(which awk)" ]; then
if [ -e "$(which bat)" ]; then
printf " \n NOTE: Press Control+O to open file in VSCode on previewing screen. \n"
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/plugins/fif.sh
printf " \n \n" >>~/.zshrc
cat fif.sh >>~/.zshrc
printf " \n \n" >>~/.zshrc
printf " \n \n" >>~/.bashrc
cat fif.sh >>~/.bashrc
printf " \n \n" >>~/.bashrc
rm ./fif.sh
printf " \n fzf-ripgrep-bat-vscode-integration was installed. \n"
else
printf " \n We could not find bat ( sharkdp/bat ) executable file. \n Please install bat by package manager i.e. Homebrew. \n"
fi
else
printf " \n We could not find awk ( GNU awk ) executable file. \n Please install awk by package manager i.e. Homebrew. \n"
fi
else
printf " \n We could not find ripgrep ( BurntSushi/ripgrep ) executable file. \n Please install ripgrep by package manager i.e. Homebrew. \n"
fi
}
function fzf-setup() {
printf "\n Setting up junegunn/fzf . \n"
## fzf official installer
if [ -e "$(which unzip)" ]; then
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
cd ~/.fzf
git pull
cp ./install ./fzf_install
printf " \n exit " >>./fzf_install
bash ~/.fzf/fzf_install
# zsh ~/.fzf/fzf_install
rm ./fzf_install
printf " \n junegunn/fzf was installed. \n"
## install fzf before installing the integration
printf " \n This plugin helps you preview colored search result and open that file in Visual Studio Code . \n\n Would you like to install fzf-ripgrep-bat-vscode-integration ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
fzf-ripgrep-bat-vscode-integration-setup
else
printf " \n Skipped fzf-ripgrep-bat-vscode-integration installation. \n"
fi
else
printf " \n We could not find unzip executable file. \n Please install unzip by package manager i.e. Homebrew. \n"
fi
}
function oh-my-fish-setup() {
printf "\n Setting up oh-my-fish/oh-my-fish . \n"
## oh-my-fish official installer start
if [ -e "$(which fish)" ]; then
printf " \n Please press Y to install over existing installation. \n"
# curl -ksSLO https://raw.githubusercontent.com/oh-my-fish/oh-my-fish/master/bin/install
## make sure fish exit and go back to zsh shell after installing oh-my-fish
# printf " \n exit" >>./install
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/fish_plugins/install
fish ./install
rm ./install
printf " \n oh-my-fish/oh-my-fish was installed. \n"
else
printf " \n We could not find fish shell executable file. \n Please install fish shell by package manager i.e. Homebrew. \n"
fi
## oh-my-fish official installer . end.
## random_omf_theme .start.
printf " \n Would you like to enable random theme for oh-my-fish ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
git clone --depth=1 https://github.com/MilkyMAISHIRANUI/random_omf_theme "$OMF_PATH/themes/random_omf_theme"
echo "random_omf_theme" > "$OMF_CONFIG/theme"
mv -f ~/.config/fish/functions/fish_prompt.fish ~/.config/fish/functions/fish_prompt.fish.old
printf " \n random themes of oh-my-fish are enabled. \n"
else
printf " \n The default theme of oh-my-fish is enabled. \n"
fi
## random_omf_theme . End.
}
function ble-sh-setup() {
printf " \n Setting up akinomyoga/ble.sh . \n"
## detect gnu awk make
if [ -e "$(which awk)" ]; then
if [ -e "$(which make)" ]; then
printf " \n NOTE: Please visit software project homepage for installation guide. \n https://github.com/akinomyoga/ble.sh \n"
## ble.sh official installer
git clone --recursive --depth=1 https://github.com/akinomyoga/ble.sh.git
make -C ble.sh install PREFIX=~/.local
echo 'source ~/.local/share/blesh/ble.sh' >>~/.bashrc
## ble.sh official installer uses echo command. printf is better.
## curl -ksSLOL https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/bash_plugins/ble.sh_bashrc_default
## printf " \n \n" >> ~/.bashrc
## cat ble.sh_bashrc_default >> ~/.bashrc
## printf " \n \n" >> ~/.bashrc
## rm ./ble.sh_bashrc_default
printf " \n akinomyoga/ble.sh was installed. \n"
else
printf " \n We could not find make ( GNU make aka gmake ) executable file. \n Please install make by package manager i.e. Homebrew. \n"
fi
else
printf " \n We could not find awk ( GNU awk ) executable file. \n Please install awk by package manager i.e. Homebrew. \n"
fi
}
function oh-my-bash-setup(){
printf " \n Setting up ohmybash/oh-my-bash . \n"
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/bash_plugins/install.sh
bash ./install.sh
rm ./install.sh
printf " \n ohmybash/oh-my-bash was installed. \n"
printf " \n Would you like to enable random theme for oh-my-bash ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
if [ -e "$(which sed)" ]; then
## perl command output nothing
## perl -pe 's/OSH_THEME=\K\d+/random/' ~/.bashrc > ~/.bashrc
## theme font is default theme of oh-my-bash
mv -f ~/.bashrc ~/.bashrc.old
sed '/^OSH_THEME/s/=.*$/=\"random\"/g' ~/.bashrc.old >~/.bashrc
else
printf " \n We could not find sed executable file. \n Please install sed by package manager i.e. Homebrew. \n"
fi
else
printf " \n The default theme of oh-my-bash is enabled. \n"
fi
}
function oh-my-bash-setup_manually() {
printf " \n Setting up ohmybash/oh-my-bash . \n"
## oh-my-bash official installer
## bash -c "$(curl -fsSL https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh)"
# curl -ksSLO https://raw.githubusercontent.com/ohmybash/oh-my-bash/master/tools/install.sh
## bash will not exit after installing oh-my-bash
# printf " \n exit" >>./install.sh
# bash ./install.sh
# rm ./install.sh
# printf " \n \n" >>~/.bashrc
printf "\nexport OSH=\"\$HOME/.oh-my-bash/\" " >>~/.bashrc
git clone --depth=1 https://github.com/ohmybash/oh-my-bash.git ~/.oh-my-bash/
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/bash_plugins/oh-my-bash_bashrc_default
printf " \n" >>~/.bashrc
cat oh-my-bash_bashrc_default >>~/.bashrc
# printf "\nexport ZSH=\"\$HOME/.oh-my-zsh/\"\nsource \"\$ZSH/oh-my-zsh.sh\" \nsource \"\$ZSH/custom/plugins/oh-my-zshrc.sh\"" >>~/.zshrc
# printf " \n" >>~/.zshrc
# printf 'source $ZSH/oh-my-zsh.sh ' >>~/.zshrc
printf "\nsource \"\$OSH/custom/plugins/oh-my-bashrc.sh\"" >>~/.bashrc
printf "export OSH=\"\$HOME/.oh-my-bash/\"\nsource \"\$OSH/oh-my-bash.sh\"" > "$OSH/custom/plugins/oh-my-bashrc.sh"
## ohmyzsh did not start on termux on Android . we need to source ohmyzsh again.
printf " \n ohmybash/oh-my-bash was installed. \n"
printf " \n Would you like to enable random theme for oh-my-bash ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
if [ -e "$(which sed)" ]; then
## perl command output nothing
## perl -pe 's/OSH_THEME=\K\d+/random/' ~/.bashrc > ~/.bashrc
## theme font is default theme of oh-my-bash
mv -f ~/.bashrc ~/.bashrc.old
sed '/^OSH_THEME/s/=.*$/=\"random\"/g' ~/.bashrc.old >~/.bashrc
else
printf " \n We could not find sed executable file. \n Please install sed by package manager i.e. Homebrew. \n"
fi
else
printf " \n The default theme of oh-my-bash is enabled. \n"
fi
}
function powerlevel10k-setup() {
printf " \n Setting up romkatv/powerlevel10k . \n"
## install powerlevel10k into ohmyzsh. start
## Install powerlevel10k into ohmyzsh so it can be used as a random theme.
# znap source romkatv/powerlevel10k
## execute znap source romkatv/powerlevel10k command on zsh startup will make powerlevel10k be the only available theme.
## echo 'znap source romkatv/powerlevel10k' >>~/.zshrc
# cd ~/zsh-snap
# mv powerlevel10k ohmyzsh/custom/themes/
# cd ~/zsh-snap
# ln -s ohmyzsh/custom/themes/powerlevel10k/
# cd ~
# printf " \n \n Use this command to use powerlevel10k theme. \n Or write this command into ~/.zshrc file. \n \n"
# printf " znap prompt ohmyzsh/ohmyzsh powerlevel10k"
# printf " \n romkatv/powerlevel10k was installed. \n"
## powerlevel10k official installer
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "$ZSH/custom/themes/powerlevel10k"
if [ -e "$(which sed)" ]; then
## perl command output nothing
## perl -pe 's/OSH_THEME=\K\d+/random/' ~/.bashrc > ~/.bashrc
## theme font is default theme of oh-my-bash
mv -f ~/.zshrc ~/.zshrc.old
sed '/^ZSH_THEME/s/=.*$/=\"powerlevel10k\/powerlevel10k\"/g' ~/.zshrc.old >~/.zshrc
printf " \n powerlevel10k is enabled as zsh theme. \n"
else
printf " \n We could not find sed executable file. \n Please install sed by package manager i.e. Homebrew. \n"
fi
## install powerlevel10k into ohmyzsh. End
}
function ohmyzsh_setup(){
printf " \n Setting up ohmyzsh/ohmyzsh. \n"
# curl -ksSLO https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
## zsh will not exit after installing ohmyzsh, therefore plugins_setup will be interupted.
# printf " \n exit" >>./install.sh
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/zsh_plugins/install.sh
zsh ./install.sh
rm ./install.sh
printf " \n Would you like to enable random theme for zsh ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
# printf " \n znap prompt ohmyzsh/ohmyzsh random \n" >>~/.zshrc
printf " \n" >>~/.zshrc
printf 'ZSH_THEME="random" ' >>~/.zshrc
printf " \n" >>~/.zshrc
printf " \n random theme for zsh is enabled. \n"
else
#echo No
printf " \n" >>~/.zshrc
printf 'ZSH_THEME="robbyrussell" ' >>~/.zshrc
printf " \n" >>~/.zshrc
printf " \n default theme robbyrussell of ohmyzsh is enabled. \n"
fi
## zsh random theme . End.
printf " \n ohmyzsh/ohmyzsh was installed. \n"
## install ohmyzsh via zsh-snap. End
# powerlevel10k setup. start.
printf " \n romkatv/powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience. \n\n Would you like to install romkatv/powerlevel10k as ohmyzsh theme ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
powerlevel10k-setup
else
#echo No
printf " \n Skipped romkatv/powerlevel10k installation. \n"
fi
# powerlevel10k setup. End.
## install powerlevel10k. end.
}
function ohmyzsh_setup_manually() {
printf " \n Setting up ohmyzsh/ohmyzsh. \n"
## install ohmyzsh via zsh-snap. start
## Install ohmyzsh outside zsh-snap may cause compatibility issues between ohmyzsh and zsh-snap.
## Use this command to execute desired plugins of ohmyzsh.
# znap source ohmyzsh/ohmyzsh lib/{git,theme-and-appearance}
## splash symbol following directory name
# mv -f ~/Git/ohmyzsh/* ~/.oh-my-zsh/*
# printf 'znap source ohmyzsh/ohmyzsh lib/{git,theme-and-appearance}' >>~/.zshrc
## Path to your oh-my-zsh installation.
git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh/
znap source ohmyzsh/ohmyzsh
# printf " \n \n \n" >>~/.zshrc
printf "\nexport ZSH=\"\$HOME/.oh-my-zsh/\"\nsource \"\$ZSH/oh-my-zsh.sh\" \nsource \"\$ZSH/custom/plugins/oh-my-zshrc.sh\"" >>~/.zshrc
# printf " \n" >>~/.zshrc
# printf 'source $ZSH/oh-my-zsh.sh ' >>~/.zshrc
printf "export ZSH=\"\$HOME/.oh-my-zsh/\"\nsource \"\$ZSH/oh-my-zsh.sh\"" > "$ZSH/custom/plugins/oh-my-zshrc.sh"
## ohmyzsh did not start on termux on Android . we need to source ohmyzsh again.
# printf " \n" >>~/.zshrc
## zsh random theme . start.
# printf " \n \n Use this command to use a random theme. \n Or write this command into ~/.zshrc file. \n \n"
# printf " znap prompt ohmyzsh/ohmyzsh random"
printf " \n Would you like to enable random theme for zsh ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
# printf " \n znap prompt ohmyzsh/ohmyzsh random \n" >>~/.zshrc
printf " \n" >>~/.zshrc
printf 'ZSH_THEME="random" ' >>~/.zshrc
printf " \n" >>~/.zshrc
printf " \n random theme for zsh is enabled. \n"
else
#echo No
printf " \n" >>~/.zshrc
printf 'ZSH_THEME="robbyrussell" ' >>~/.zshrc
printf " \n" >>~/.zshrc
printf " \n default theme robbyrussell of ohmyzsh is enabled. \n"
fi
## zsh random theme . End.
printf " \n ohmyzsh/ohmyzsh was installed. \n"
## install ohmyzsh via zsh-snap. End
# powerlevel10k setup. start.
printf " \n romkatv/powerlevel10k is a theme for Zsh. It emphasizes speed, flexibility and out-of-the-box experience. \n\n Would you like to install romkatv/powerlevel10k as ohmyzsh theme ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
powerlevel10k-setup
else
#echo No
printf " \n Skipped romkatv/powerlevel10k installation. \n"
fi
# powerlevel10k setup. End.
## install powerlevel10k. end.
}
function zsh-autocomplete-setup() {
## fish-like autocomplete by these 3 plugins . start.
printf "\nSetting up fish-like autocompletion plugins for zsh.\n"
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/zsh_plugins/fish-like.plugin.zsh
# printf " \n \n" >>~/.zshrc
# cat ./zsh-autocomplete-setup.sh >>~/.zshrc
# printf " \n \n" >>~/.zshrc
mv ./fish-like.plugin.zsh ~/Git/fish-like.plugin.zsh
printf "source ~/Git/fish-like.plugin.zsh"
# znap source marlonrichert/zsh-autocomplete
# znap source zsh-users/zsh-autosuggestions
# znap source zsh-users/zsh-completions
# znap source zsh-users/zsh-syntax-highlighting
## load plugins manually because znap is not compatible with msys2.
# source ~/Git/zsh-autocomplete/zsh-autocomplete.plugin.zsh
# source ~/Git/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
# source ~/Git/zsh-completions/zsh-completions.plugin.zsh
# source ~/Git/zsh-syntax-highlighting/zsh-syntax-highlighting.plugin.zsh
printf "\nfish-like autocompletion plugins for zsh are installed.\n"
## fish-like autocomplete. end.
}
function zsh-plugins-setup() {
printf " \n \n" >>~/.zshrc
printf 'export ZSH="$HOME/.oh-my-zsh/" ' >>~/.zshrc
## termux on Android does not load ohmyzsh on startup.
# printf " \n source ~/.zshrc " >>~/.zprofile
## install marlonrichert/zsh-snap . start
printf " \n Setting up marlonrichert/zsh-snap . \n"
## copy zsh plugins default settings to ~/.zshrc
curl -ksSLO https://github.com/MilkyMAISHIRANUI/unix_shell_plugins_setup/raw/main/zsh_plugins/zshrc_default
printf " \n \n" >>~/.zshrc
cat zshrc_default >>~/.zshrc
printf " \n \n" >>~/.zshrc
rm ./zshrc_default
## zsh-snap official installer
printf " \n \n Please keep the default installation directory unless you know what you are doing. \n \n"
## install znap in official default path
git clone --depth 1 -- https://github.com/marlonrichert/zsh-snap.git ~/Git/zsh-snap
chmod +x ~/Git/zsh-snap/znap.zsh
source ~/Git/zsh-snap/znap.zsh
## use zshrc-default instead of echo >> zshrc . echo does not support text format well.
## echo 'source ~/Git/zsh-snap/znap.zsh' >> ~/.zshrc
## zshrc-default should not includes zsh-autocomplete.
printf " \n marlonrichert/zsh-snap was installed. \n"
## install marlonrichert/zsh-snap . End
## marlonrichert/zsh-autocomplete setup . start.
printf " \n marlonrichert/zsh-autocomplete adds real-time type-ahead autocompletion to Zsh. \n\n Would you like to install marlonrichert/zsh-autocomplete ? [y/n] \n"
read answer
if [ "$answer" != "${answer#[Yy]}" ]; then
#echo Yes
zsh-autocomplete-setup
else
#echo No
printf " \n Skipped marlonrichert/zsh-autocomplete installation. \n"
fi
## marlonrichert/zsh-autocomplete setup . end .
}
function exit_succeeded_cleanup() {
printf "Setup completed. \n If you like this script, please give it a star. \n"
cd "$last_working_directory"
rm ./unix_shell_plugins_setup.sh
cd "$last_working_directory"
exit 0
}
function exiting_cleanup() {
printf " \n Setup completed. \n Open a new terminal window to enjoy it. \n If unix shell went wrong, please follow this guide. \n \n https://github.com/marlonrichert/zsh-autocomplete#manual-installation \n \n You may try to rename or delete dotfiles such as ~/.zshrc , ~/.zprofile , ~/.p10k.zsh , ~/.bashrc , ~/.bash_profile, ~/.config/fish/conf.d , and the folder of plugins ( usually at ~/ ) . \n Then execute this script again. \n \n If you like this script, please give it a star on its home page. \n \n"
cd "$last_working_directory"
rm ./unix_shell_plugins_setup.sh
cd "$last_working_directory"
exit 0
}
function exit_canceled_cleanup() {
printf " \n Setup canceled. Your system was not modified. \n If you like this script, please give it a star. \n"
cd "$last_working_directory"
rm ./unix_shell_plugins_setup.sh
cd "$last_working_directory"
exit 1
}
main