-
Notifications
You must be signed in to change notification settings - Fork 38
/
BlaCk-Void-Zsh.sh
executable file
ยท228 lines (202 loc) ยท 5.75 KB
/
BlaCk-Void-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
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
#!/bin/bash
# shellcheck disable=SC1091
# shellcheck source=./install_font.sh
echo "----------------------------------------"
echo " BlaCk-Void Zsh Setup"
echo "----------------------------------------"
set -e
BVZSH=$( cd "$(dirname "$0")" ; pwd )
echo ""
echo "--------------------"
echo " Downloads"
echo ""
ARH_RELEASE="arch\|Manjaro\|Chakra"
DEB_RELEASE="[Dd]ebian\|[Uu]buntu|[Mm]int|[Kk]noppix"
YUM_RELEASE="rhel\|CentOS\|RED\|Fedora"
ARH_PACKAGE_NAME=(zsh curl git w3m wmctrl ack tmux xdotool python-pip powerline)
DEB_PACKAGE_NAME=(zsh curl git w3m-img wmctrl ack tmux xdotool python3-pip powerline)
YUM_PACKAGE_NAME=(zsh curl git w3m-img wmctrl ack tmux xdotool python3-pip powerline)
MAC_PACKAGE_NAME=(zsh curl git socat w3m wmctrl ack tmux xdotool python3 xquartz)
BSD_PACKAGE_NAME=(zsh curl git thefuck w3m-img xdotool p5-ack tmux xdotool py37-pip py37-powerline-status)
PIP_PACKAGE_NAME=(thefuck)
PACAPT="/usr/local/bin/pacapt"
PACAPT_INSTALLED=true
pacapt_install()
{
if ! [ -x "$(command -v pacapt)" ]; then
echo "Universal Package Manager(icy/pacapt) Download && Install(need sudo permission)"
sudo curl https://github.com/icy/pacapt/raw/ng/pacapt -Lo $PACAPT
sudo chmod 755 $PACAPT
sudo ln -sv $PACAPT /usr/local/bin/pacman || true
PACAPT_INSTALLED=false
fi
sudo pacapt -Sy
}
arh_install()
{
sudo pacapt -S --noconfirm "${ARH_PACKAGE_NAME[@]}"
}
deb_install()
{
sudo pacapt -S --noconfirm "${DEB_PACKAGE_NAME[@]}"
}
yum_install()
{
sudo pacapt -S --noconfirm "${YUM_PACKAGE_NAME[@]}"
}
mac_install()
{
brew update
brew install "${MAC_PACKAGE_NAME[@]}"
sudo pip3 install powerline-status
}
bsd_install()
{
pacapt -S --noconfirm "${BSD_PACKAGE_NAME[@]}"
}
set_brew()
{
if ! [ -x "$(command -v brew)" ]; then
echo "Now, Install Brew." >&2
bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
local BREW_PREFIX
BREW_PREFIX=$(brew --prefix)
export PATH=${BREW_PREFIX}/bin:${BREW_PREFIX}/sbin:$PATH
fi
}
pip_install()
{
if ! [ -x "$(command -v pip3)" ]; then
curl https://bootstrap.pypa.io/get-pip.py | sudo python3
fi
sudo pip3 install "${PIP_PACKAGE_NAME[@]}"
}
etc_install()
{
pip_install
mkdir ~/.zplugin
git clone https://github.com/zdharma-continuum/zinit.git ~/.zplugin/bin
curl -L "$BVZSH" https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping > "$BVZSH"/prettyping
chmod +x "$BVZSH"/prettyping
if ! [[ "$NO_FONT" == YES ]]; then
"$BVZSH"/install_font.sh
fi
}
if [[ "$OSTYPE" == "linux-gnu" ]]; then
RELEASE=$(cat /etc/*release)
pacapt_install
##ARH Package
if echo "$RELEASE" | grep ^NAME | grep Manjaro; then
arh_install
elif echo "$RELEASE" | grep ^NAME | grep Chakra ; then
arh_install
elif echo "$RELEASE" | grep ^ID | grep arch ; then
arh_install
elif echo "$RELEASE" | grep ^ID_LIKE | grep arch ; then
arh_install
##Deb Package
elif echo "$RELEASE" | grep ^NAME | grep Ubuntu ; then
ubuntu_ver=$(lsb_release -rs)
if [[ ${ubuntu_ver:0:2} -lt 18 ]]; then
DEB_PACKAGE_NAME=$( sed -e "s/ack/ack-grep/" <(echo "$DEB_PACKAGE_NAME") )
fi
deb_install
elif echo "$RELEASE" | grep ^NAME | grep Debian ; then
deb_install
elif echo "$RELEASE" | grep ^NAME | grep Mint ; then
deb_install
elif echo "$RELEASE" | grep ^NAME | grep Knoppix; then
deb_install
elif echo "$RELEASE" | grep ^ID_LIKE | grep debian ; then
deb_install
##Yum Package
elif echo "$RELEASE" | grep ^NAME | grep CentOS ; then
yum_install
elif echo "$RELEASE" | grep ^NAME | grep Red ; then
yum_install
elif echo "$RELEASE" | grep ^NAME | grep Fedora ; then
yum_install
elif echo "$RELEASE" | grep ^ID_LIKE | grep rhel ; then
yum_install
else
echo "OS NOT DETECTED, try to flexible mode.."
if echo "$RELEASE" | grep "$ARH_RELEASE" > /dev/null 2>&1; then
arh_install
elif echo "$RELEASE" | grep "$DEB_RELEASE" > /dev/null 2>&1; then
deb_install
elif echo "$RELEASE" | grep "$YUM_RELEASE" > /dev/null 2>&1; then
yum_install
fi
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
set_brew
mac_install
elif [[ "$OSTYPE" == "FreeBSD"* ]]; then
pacapt_install
bsd_install
elif uname -a | grep FreeBSD ; then
pacapt_install
bsd_install
else
echo "OS NOT DETECTED, couldn't install packages."
exit 1;
fi
etc_install
if [[ "$PACAPT_INSTALLED" == false ]]; then
sudo rm -rf "$PACAPT"
fi
echo "--------------------"
echo " Apply Settings"
echo ""
mkdir "$BVZSH"/cache
zshrc=~/.zshrc
zshenv=~/.zshenv
zlogin=~/.zlogin
zprofile=~/.zprofile
profile=~/.profile
set_file()
{
local file=$1
echo "-------"
echo "Set $file !!"
echo ""
if [ -e "$file" ]; then
echo "$file found."
echo "Now Backup.."
cp -v "$file" "$file".bak
echo ""
else
echo "$file not found."
touch "$file"
echo "$file is created"
echo ""
fi
}
set_file $zshrc
set_file $zshenv
set_file $zlogin
echo "source $BVZSH/BlaCk-Void.zshrc" >> $zshrc
echo "source $BVZSH/BlaCk-Void.zshenv" >> $zshenv
echo "source $BVZSH/BlaCk-Void.zlogin" >> $zlogin
if [ -e $profile ]; then
< $profile tee -a $zprofile
fi
latest_update_date()
{
BVZSH_PLUGIN_RECEIPT_F=${BVZSH_PLUGIN_RECEIPT_F:-.zsh_plugin_lastupdate}
BVZSH_SYSTEM_RECEIPT_F=${BVZSH_SYSTEM_RECEIPT_F:-.zsh_system_lastupdate}
date +%s > "${HOME}/$BVZSH_PLUGIN_RECEIPT_F"
date +%s > "${HOME}/$BVZSH_SYSTEM_RECEIPT_F"
echo "write latest update date"
}
latest_update_date
if ! [[ "$NO_DEFAULT" == YES ]]; then
echo "-------"
echo "ZSH as the default shell(need sudo permission)"
chsh -s "$(which zsh)"
fi
echo "Please relogin session or restart terminal"
echo "The End!!"
echo ""
echo "command: zsh-help"
echo "for BlaCk-Void Zsh update"