-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03_zsh.sh
More file actions
executable file
·117 lines (92 loc) · 2.68 KB
/
03_zsh.sh
File metadata and controls
executable file
·117 lines (92 loc) · 2.68 KB
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
#!/bin/bash
set -e
# - https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
# - https://ohmyz.sh/
if [[ "$EUID" == 0 ]]; then
echo "Please run without sudo"
exit
fi
term_color_red () {
echo -e "\e[91m"
}
term_color_white () {
echo -e "\e[39m"
}
confirmation(){
term_color_red
echo "Zsh will be installed"
echo "Existing zshrc will be deleted and installed again"
echo
echo "Do you want to install? (y/n)"
term_color_white
echo
read -n 1 ans
echo
if [[ ! $ans == "y" ]]; then
exit 1
fi
}
cleanup(){
term_color_red
echo
echo "Delete /home/$LOGNAME/.zshrc"
echo "Delete /home/$LOGNAME/.oh-my-zsh"
echo
term_color_white
rm -rf /home/$LOGNAME/.zshrc
rm -rf /home/$LOGNAME/.oh-my-zsh
}
install_omz (){
term_color_red
echo "OMZ install (w/ RUNZSH=no)"
term_color_white
export RUNZSH=no
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
cp /home/$LOGNAME/.oh-my-zsh/templates/zshrc.zsh-template /home/$LOGNAME/.zshrc
term_color_red
echo "chsh -s $(which zsh) (<= need password)"
term_color_white
chsh -s $(which zsh)
term_color_red
echo "Make zshrc to source shrc"
term_color_white
SHRC=$(cat /home/$LOGNAME/.zshrc | grep "\\.shrc" | wc -l)
if [[ ! $SHRC == "1" ]]; then
echo "" >> /home/$LOGNAME/.zshrc # for space
echo "source /home/$LOGNAME/.shrc" >> /home/$LOGNAME/.zshrc
fi
}
install_plugins(){
term_color_red
echo "Powerlevel10k install"
echo " - to enable: ZSH_THEME=\"powerlevel10k/powerlevel10k\""
echo " - to config: p10k configure"
term_color_white
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k
term_color_red
echo "Zsh-autosuggestions install"
term_color_white
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
term_color_red
echo "Update zshrc"
echo " - Add plugins to .zshrc (git golang flutter zsh-autosuggestions)"
echo " - Enable theme (powerlevel10k)"
term_color_white
sed -i 's/plugins=(git)/plugins=(git golang flutter zsh-autosuggestions dotenv)/g' /home/$LOGNAME/.zshrc
sed -i 's/ZSH_THEME=\"robbyrussell\"/ZSH_THEME=\"powerlevel10k\/powerlevel10k\"/g' /home/$LOGNAME/.zshrc
}
post(){
term_color_red
echo "Please reboot and run 'p10k prompt'"
echo "(For cloud platforms, edit /etc/pam.d/chsh - required to sufficient)"
echo
echo "Done"
echo
term_color_white
}
trap term_color_white EXIT
confirmation
cleanup
install_omz
install_plugins
post