-
Notifications
You must be signed in to change notification settings - Fork 6
/
zsh.sh
73 lines (65 loc) · 1.99 KB
/
zsh.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
# bash script to be sourced from popOS_setup.sh
# Copy .zshrc and offer to change default shell
Separate 4
printf "Successfully installed \e[36mzsh\e[00m, configuring...\n"
# Create .zshrc files
[ ! -f ~/.zshrc ] && cat "$script_location/samples/zshrc" | tee ~/.zshrc ~/.zshrc-og >/dev/null
sudo [ ! -f /root/.zshrc ] && cat "$script_location/samples/zshrc" | sudo tee /root/.zshrc /root/.zshrc-og >/dev/null
# Offer to install powerline-shell
read -rp "$(printf "Do you want to install \e[01mPowerline Shell\e[00m? (y/N) ")"
if [ ${REPLY,,} = "y" ]; then
printf "Installing \e[01mPowerline Shell\e[00m...\n"
sudo pip3 install powerline-shell &>/dev/null; O=$?
else
O=1
fi
if [ $O -eq 0 ]; then
mkdir -p ~/.config/powerline-shell
sudo mkdir -p /root/.config/powerline-shell
#region file
FILE='{
"segments": [
"virtual_env",
"username",
"hostname",
"ssh",
"cwd",
"git",
"hg",
"jobs",
"root"
],
"cwd": {
"max_depth": 3
}
}'
#endregion
printf "%s\n" "$FILE" | sudo tee /root/.config/powerline-shell/config.json | tee ~/.config/powerline-shell/config.json >/dev/null
unset FILE
fi
# Modify PATH for all users
cat <<EOF | tee -a /etc/zsh/zshenv >/dev/null
# User specific environment
if ! [[ "\$PATH" =~ "\$HOME/.local/bin" ]]; then
PATH="\$HOME/.local/bin:\$PATH"
fi
if ! [[ "\$PATH" =~ "\$HOME/bin" ]]; then
PATH="\$HOME/bin:\$PATH"
fi
export PATH
EOF
printf "Choose the prompt style you prefer: \n"
select s in $(cat "$HOME/.zshrc" | grep "# Choose a prompt style between" | sed -e 's/\s*#.*: //'); do
if [ $O -ne 0 ] && [ $s = "powerline" ]; then
printf "Sorry, powerline was not installed, choose another style\n"
continue
fi
sed -i "s/^ prompt_style=.*$/ prompt_style=$s/" ~/.zshrc
sudo sed -i "s/^ prompt_style=.*$/ prompt_style=$s/" /root/.zshrc
break
done
read -rp "Do you want to make `tput setaf 6`Z-Shell`tput sgr0` your default shell? (Y/n) "
if [[ ${REPLY,,} == "y" ]] || [ -z $REPLY ]; then
sudo usermod -s $(which zsh) $USER
sudo usermod -s $(which zsh) root
fi