This repository has been archived by the owner on Sep 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·73 lines (55 loc) · 1.79 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
install_zshrc () {
set -e
set -u
echo -e "\033[32m➤ Installing! \033[0m"
command -v git >/dev/null 2>&1 \
&& echo -e "\033[32m ✔ Found ❰ Git ❱ \033[0m" \
|| {
echo -e "\033[31m ✘ Missing ❰ Git ❱ \033[0m"
echo -e "\033[31m✘ Install failed!"
exit 1
}
if [ -d $HOME/.zgen.zsh ]; then
echo -e "\033[32m ✔ Found ❰ zgen ❱ \033[0m"
else
echo -e " ➤ Installing ❰ zgen ❱ \033[0m"
command -v git >/dev/null 2>&1 && \
env git clone https://github.com/tarjoilija/zgen.git $HOME/.zgen.zsh >/dev/null 2>&1
echo -e "\033[32m ✔ Installed ❰ zgen ❱ \033[0m"
fi
if [ -f $HOME/.zshrc ] || [ -h $HOME/.zshrc ]; then
ZSHRC_LINE=$(head -n 1 $HOME/.zshrc);
if [ "$ZSHRC_LINE" != '# rxrc/zshrc' ]; then
echo -e " ➤ Exists ❰ ~/.zshrc ❱ \033[0m"
mv $HOME/.zshrc $HOME/.zshrc.preinstall
echo -e "\033[32m ✔ Moved to ❰ ~/.zshrc.preinstall ❱ \033[0m"
else
rm $HOME/.zshrc
fi
fi
echo -e " ➤ Installing ❰ ~/.zshrc ❱ \033[0m"
tee $HOME/.zshrc >/dev/null <<EOF
# rxrc/zshrc
branch="\${ZSHRC_BRANCH:-master}"
source "\${HOME}/.zgen.zsh/zgen.zsh"
if [[ -d "\${HOME}/.zgen/local/zshrc-\${branch}" ]]; then
source "\${HOME}/.zgen/local/zshrc-\${branch}/plugins.zsh"
elif [[ -d "\${HOME}/.zgen/rxrc/zshrc-\${branch}" ]]; then
source "\${HOME}/.zgen/rxrc/zshrc-\${branch}/plugins.zsh"
else
zgen load rxrc/zshrc plugin \$branch
zgen update
echo
echo ' ✔ Installed zshrc as zgen plugin!'
echo
echo ' ➤ Press any key to exit this shell.'
echo ' ➤ Open a new shell to finish setup.'
read -s -n 1
exit 0
fi
EOF
echo -e "\033[32m ✔ Installed ❰ ~/.zshrc ❱ \033[0m"
echo -e "\033[32m✔ Install complete! \033[0m"
exit 0
}
install_zshrc