-
Notifications
You must be signed in to change notification settings - Fork 67
/
install
executable file
·214 lines (184 loc) · 5.79 KB
/
install
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
#!/bin/bash
#adwpc
#it will update your packages !
OBJ=""
BE="NO"
FE="NO"
NVIM="NO"
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
CPU=`cat /proc/cpuinfo | grep "processor" | wc -l`
MEM=`free -b|grep "Mem"|awk -F' ' '{print $2}'`
OS_TYPE=$NAME
unset NAME
OS_VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
CPU=`cat /proc/cpuinfo | grep "processor" | wc -l`
MEM=`free -b|grep "Mem"|awk -F' ' '{print $2}'`
OS_TYPE=$(lsb_release -si)
OS_VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
CPU=`cat /proc/cpuinfo | grep "processor" | wc -l`
MEM=`free -b|grep "Mem"|awk -F' ' '{print $2}'`
OS_TYPE=$DISTRIB_ID
OS_VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
CPU=`cat /proc/cpuinfo | grep "processor" | wc -l`
MEM=`free -b|grep "Mem"|awk -F' ' '{print $2}'`
OS_TYPE=Debian
OS_VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
CPU=`cat /proc/cpuinfo | grep "processor" | wc -l`
MEM=`free -b|grep "Mem"|awk -F' ' '{print $2}'`
...
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
CPU=`cat /proc/cpuinfo | grep "processor" | wc -l`
MEM=`free -b|grep "Mem"|awk -F' ' '{print $2}'`
...
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS_TYPE=$(uname -s)
OS_VER=$(uname -r)
CPU=`sysctl -n machdep.cpu.thread_count`
MEM=`sysctl -n hw.memsize`
fi
function config()
{
read -r -p "Support go c/c++? [Y/n]" input
case $input in
[yY][eE][sS] | [yY])
BE="YES"
;;
[nN][oO] | [nN]) ;;
\
*)
echo "Invalid input..."
exit 1
;;
esac
read -r -p "Support javascript/html? [Y/n] " input
case $input in
[yY][eE][sS] | [yY])
FE="YES"
;;
[nN][oO] | [nN]) ;;
\
*)
echo "Invalid input..."
exit 1
;;
esac
read -r -p "Install NeoVim(recommend)? [Y/n] " input
case $input in
[yY][eE][sS] | [yY])
NVIM="YES"
;;
[nN][oO] | [nN]) ;;
\
*)
echo "Invalid input..."
exit 1
;;
esac
}
function vimrc_dep_inst()
{
if [[ "$OS_TYPE" =~ "CentOS" ]];then
if [[ "$BE" == "YES" ]];then
sudo yum -y install epel-release
sudo yum install -y ctags cscope cmake python-devel git python python-pip gcc gcc-c++
fi
if [[ "$FE" == "YES" ]];then
sudo yum install -y nodejs
# support js html autoformat autocomplete syntastic
sudo npm --registry https://registry.npm.taobao.org install -g eslint eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard eslint-config-standard js-beautify
fi
fi
if [[ "$OS_TYPE" == "Ubuntu" ]];then
if [[ "$BE" == "YES" ]];then
sudo apt-get install -y ctags cscope cmake python-dev git python python-pip gcc g++
fi
if [[ "$FE" == "YES" ]];then
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
# support js html autoformat autocomplete syntastic
sudo npm --registry https://registry.npm.taobao.org install -g eslint eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard eslint-config-standard js-beautify
fi
fi
if [[ "$OS_TYPE" == "Darwin" ]];then
if [[ "$BE" == "YES" ]];then
brew install ctags cscope git
fi
if [[ "$FE" == "YES" ]];then
brew install nodejs
# support js html autoformat autocomplete syntastic
sudo npm --registry https://registry.npm.taobao.org install -g eslint eslint-plugin-import eslint-plugin-node eslint-plugin-promise eslint-plugin-standard eslint-config-standard js-beautify
fi
fi
}
function linux_nvim_inst()
{
cd /tmp
wget https://github.com/neovim/neovim/releases/download/v0.4.3/nvim-linux64.tar.gz
sudo tar xf nvim-linux64.tar.gz -C /usr/local/
sudo mv /bin/vim /bin/vim.bak.`date +%Y%m%d%H%M%S`
sudo ln -s /usr/local/nvim-linux64/bin/nvim /bin/vim
mv ~/.config/nvim ~/.config/nvim.bak.`date +%Y%m%d%H%M%S`
mv ~/.config/nvim/init.vim ~/.config/nvim/init.vim.bak.`date +%Y%m%d%H%M%S`
mkdir -p ~/.config
ln -s ~/.vim ~/.config/nvim
ln -s ~/.vimrc ~/.config/nvim/init.vim
sudo yum install -y python python3
sudo pip install pynvim
sudo pip3 install pynvim
}
function vim_inst()
{
if [[ "$OS_TYPE" =~ "CentOS" && "$OS_VER" == "7" ]];then
linux_nvim_inst
fi
if [[ "$OS_TYPE" =~ "CentOS" && "$OS_VER" == "6" ]];then
linux_nvim_inst
fi
if [[ "$OS_TYPE" == "Ubuntu" ]];then
linux_nvim_inst
fi
if [[ "$OS_TYPE" == "Darwin" ]];then
brew install neovim
pip2 install neovim
pip3 install neovim
fi
}
function vimrc_inst()
{
#install depends
config
vimrc_dep_inst
# install vim config and plugin
mv ~/.vimrc ~/.vimrc.bak.`date +%Y%m%d%H%M%S`
mv ~/.vim ~/.vim.bak.`date +%Y%m%d%H%M%S`
cp -rf .vimrc ~
cp -rf .vim ~
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim -u ~/.vimrc -c ":PlugInstall" -c ":q" -c ":q"
#install ycm
cd ~/.vim/plugged/YouCompleteMe/ ; git submodule update --init --recursive ; git submodule update --init --recursive ; ./install.py --all
vim_inst
}
if [ "$1" != "" ];then
OBJ=$1
fi
case "$OBJ" in
vimrc) vimrc_inst;;
*) echo "Usage: install {vimrc}" >&2
exit 1
;;
esac