-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·384 lines (342 loc) · 9.13 KB
/
install.sh
File metadata and controls
executable file
·384 lines (342 loc) · 9.13 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
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#!/usr/bin/env bash
# 拷贝文件
function copy_files()
{
rm -rf ~/.vimrc
ln -s ${PWD}/.vimrc ~
mkdir ~/.vim
rm -rf ~/.vim/colors
ln -s ${PWD}/colors ~/.vim
rm -rf ~/.vim/ftplugin
ln -s ${PWD}/ftplugin ~/.vim
rm -rf ~/.vim/autoload
ln -s ${PWD}/autoload ~/.vim
ln -s ${PWD}/coc/coc-settings.json ~/.vim/coc-settings.json
}
# 安装coc插件
function install_plug()
{
mkdir ~/.vim/plugged
./shell/plug.sh
# tar -zxvf ${PWD}/vim.tar.gz -C ~/.vim/plugged/
# sudo curl -sL install-node.now.sh | sudo bash
# curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
sudo ./shell/nodejs.sh
npm config set registry https://registry.npmmirror.com
echo 'coc.nvim:registry https://registry.npmmirror.com' >> ~/.npmrc
# https://registry.npmjs.org/
# npm install -g yarn
# yarn config set registry 'https://registry.npm.taobao.org'
# git clone https://gitee.com/zgpio/markdown-preview.nvim.git ~/.vim/plugged/markdown-preview.nvim
# cd ~/.vim/plugged/markdown-preview.nvim/app
# yarn install
git clone -b release https://gitee.com/zgpio/coc.nvim.git ~/.vim/plugged/coc.nvim
root_path=${PWD}
cd ~/.vim/plugged/coc.nvim
git reset --hard v0.0.82
# yarn install
# yarn build
vim -c "PlugInstall" -c "qa"
if [ -d ~/.vim/plugged/vim-airline/autoload/airline/extensions ];then
mv $root_path/vimscript/branch.vim ~/.vim/plugged/vim-airline/autoload/airline/extensions
# mv ${PWD}/vimscript/coc.vim ~/.vim/plugged/vim-airline/autoload/airline/extensions
fi
chmod 664 ~/.viminfo
}
# 安装vim插件
function install_vim_plugin()
{
vim -c "PlugInstall" -c "qa"
}
# 安装linux平台字体
function install_fonts_on_linux()
{
mkdir -p ~/.local/share/fonts
cp ./fonts/DejaVuSansMNerdFontMono-Regular.ttf ~/.local/share/fonts
fc-cache -vf ~/.local/share/fonts
}
# 打印logo
function print_logo()
{
color="$(tput setaf 6)"
normal="$(tput sgr0)"
printf "${color}"
echo ' _ __ _ '
echo ' (_) / _| | | '
echo '__ ___ _ __ ___ | |_ __ _ ___| |_ '
echo '\ \ / / | "_ " _ \| _/ _" / __| __|'
echo ' \ V /| | | | | | | || (_| \__ \ |_ '
echo ' \_/ |_|_| |_| |_|_| \__,_|___/\__|'
echo ''
echo 'install ok'
echo 'Just enjoy it!'
echo 'p.s. Follow me at https://github.com/chenxuan520.'
echo ''
printf "${normal}"
}
# 开始安装vimplus
function begin_install_vimplus()
{
copy_files
install_fonts_on_linux
install_plug
print_logo
}
# 安装mac必备软件
function install_prepare_software_on_mac()
{
type brew
if [ $? == 1 ];then
curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh
echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zprofile
echo 'please make sure brew is installed,and run it angin'
exit 1
fi
brew install nodejs
brew install zip wget git ctags fzf ripgrep
}
# 安装ubuntu必备软件
function install_prepare_software_on_ubuntu()
{
type apt
if [ $? == 1 ];then
return
fi
sudo apt-get update
sudo apt-get install -y vim
sudo apt-get install -y zip curl git wget ctags ripgrep fzf
sudo apt-get install -y build-essential python python-dev python3-dev fontconfig ack-grep ack
sudo apt-get install -y universal-ctags || sudo apt-get install -y exuberant-ctags
}
# 安装debian必备软件
function install_prepare_software_on_debian()
{
type apt
if [ $? == 1 ];then
return
fi
sudo apt-get update
sudo apt-get install -y vim
sudo apt-get install -y zip curl git wget ctags ripgrep fzf
sudo apt-get install -y build-essential python python-dev python3-dev fontconfig ack
sudo apt-get install -y universal-ctags || sudo apt-get install -y exuberant-ctags
sudo apt-get install -y vim cmake build-essential python python-dev python3-dev fontconfig ack git
}
# 安装tmux必备软件
function install_prepare_software_on_tmux()
{
pkg update
pkg install -y vim
pkg install -y zip curl git wget ctags ripgrep
pkg install -y build-essential python python-dev python3-dev fontconfig libfile-next-perl ack-grep ack
pkg install -y universal-ctags || sudo apt-get install -y exuberant-ctags
}
# 获取linux发行版名称
function get_linux_distro()
{
if grep -Eq "Ubuntu" /etc/*-release; then
echo "Ubuntu"
elif grep -Eq "Deepin" /etc/*-release; then
echo "Deepin"
elif grep -Eq "Raspbian" /etc/*-release; then
echo "Raspbian"
elif grep -Eq "uos" /etc/*-release; then
echo "UOS"
elif grep -Eq "LinuxMint" /etc/*-release; then
echo "LinuxMint"
elif grep -Eq "elementary" /etc/*-release; then
echo "elementaryOS"
elif grep -Eq "Debian" /etc/*-release; then
echo "Debian"
elif grep -Eq "Kali" /etc/*-release; then
echo "Kali"
elif grep -Eq "Parrot" /etc/*-release; then
echo "Parrot"
elif grep -Eq "CentOS" /etc/*-release; then
echo "CentOS"
elif grep -Eq "fedora" /etc/*-release; then
echo "fedora"
elif grep -Eq "openSUSE" /etc/*-release; then
echo "openSUSE"
elif grep -Eq "Arch Linux" /etc/*-release; then
echo "ArchLinux"
elif grep -Eq "ManjaroLinux" /etc/*-release; then
echo "ManjaroLinux"
elif grep -Eq "Gentoo" /etc/*-release; then
echo "Gentoo"
elif grep -Eq "alpine" /etc/*-release; then
echo "Alpine"
else
echo "Unknow"
fi
}
# 获取日期
function get_datetime()
{
time=$(date "+%Y%m%d%H%M%S")
echo $time
}
# 判断文件是否存在
function is_exist_file()
{
filename=$1
if [ -f $filename ]; then
echo 1
else
echo 0
fi
}
# 判断目录是否存在
function is_exist_dir()
{
dir=$1
if [ -d $dir ]; then
echo 1
else
echo 0
fi
}
#备份原有的.vimrc文件
function backup_vimrc_file()
{
old_vimrc=$HOME"/.vimrc"
is_exist=$(is_exist_file $old_vimrc)
if [ $is_exist == 1 ]; then
time=$(get_datetime)
backup_vimrc=$old_vimrc"_bak_"$time
read -p "Find "$old_vimrc" already exists,backup "$old_vimrc" to "$backup_vimrc"? [Y/N] " ch
if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then
cp $old_vimrc $backup_vimrc
fi
fi
}
#备份原有的.vimrc.custom.plugins文件
function backup_vimrc_custom_plugins_file()
{
old_vimrc_plugins=$HOME"/.vimrc.custom.plugins"
is_exist=$(is_exist_file $old_vimrc_plugins)
if [ $is_exist == 1 ]; then
time=$(get_datetime)
backup_vimrc_plugins=$old_vimrc_plugins"_bak_"$time
read -p "Find "$old_vimrc_plugins" already exists,backup "$old_vimrc_plugins" to "$backup_vimrc_plugins"? [Y/N] " ch
if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then
cp $old_vimrc_plugins $backup_vimrc_plugins
fi
fi
}
#备份原有的.vimrc.custom.config文件
function backup_vimrc_custom_config_file()
{
old_vimrc_config=$HOME"/.vimrc.custom.config"
is_exist=$(is_exist_file $old_vimrc_config)
if [ $is_exist == 1 ]; then
time=$(get_datetime)
backup_vimrc_config=$old_vimrc_config"_bak_"$time
read -p "Find "$old_vimrc_config" already exists,backup "$old_vimrc_config" to "$backup_vimrc_config"? [Y/N] " ch
if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then
cp $old_vimrc_config $backup_vimrc_config
fi
fi
}
#备份原有的.vim目录
function backup_vim_dir()
{
old_vim=$HOME"/.vim"
is_exist=$(is_exist_dir $old_vim)
if [ $is_exist == 1 ]; then
time=$(get_datetime)
backup_vim=$old_vim"_bak_"$time
read -p "Find "$old_vim" already exists,backup "$old_vim" to "$backup_vim"? [Y/N] " ch
if [[ $ch == "Y" ]] || [[ $ch == "y" ]]; then
cp -R $old_vim $backup_vim
fi
fi
}
# 备份原有的.vimrc和.vim
function backup_vimrc_and_vim()
{
backup_vimrc_file
backup_vimrc_custom_plugins_file
backup_vimrc_custom_config_file
backup_vim_dir
}
# 在mac上安装vimfast
function install_vimplus_on_mac()
{
backup_vimrc_and_vim
install_prepare_software_on_mac
begin_install_vimplus
}
# 在ubuntu上安装vimplus
function install_vimplus_on_ubuntu()
{
backup_vimrc_and_vim
install_prepare_software_on_ubuntu
begin_install_vimplus
}
# 在debian上安装vimplus
function install_vimplus_on_debian()
{
backup_vimrc_and_vim
install_prepare_software_on_debian
begin_install_vimplus
}
function install_vimplus_on_tmux()
{
backup_vimrc_and_vim
install_prepare_software_on_tmux
begin_install_vimplus
}
# 在linux平上台安装vimplus
function install_vimplus_on_linux()
{
distro=`get_linux_distro`
echo "Linux distro: "${distro}
if [ ${distro} == "Ubuntu" ]; then
install_vimplus_on_ubuntu
elif [ ${distro} == "Deepin" ]; then
install_vimplus_on_ubuntu
elif [ ${distro} == "LinuxMint" ]; then
install_vimplus_on_ubuntu
elif [ ${distro} == "elementaryOS" ]; then
install_vimplus_on_ubuntu
elif [ ${distro} == "Debian" ]; then
install_vimplus_on_debian
elif [ ${distro} == "Raspbian" ]; then
install_vimplus_on_debian
elif [ ${distro} == "UOS" ]; then
install_vimplus_on_debian
elif [ ${distro} == "Kali" ]; then
install_vimplus_on_debian
else
echo "Not support linux distro: "${distro}
fi
}
# 获取当前时间戳
function get_now_timestamp()
{
cur_sec_and_ns=`date '+%s-%N'`
echo ${cur_sec_and_ns%-*}
}
function main(){
begin=`get_now_timestamp`
type=$(uname)
echo "Platform type: "${type}
if [ ${type} == "Linux" ]; then
tp=$(uname -a)
if [[ $tp =~ "Android" ]]; then
install_vimplus_on_tmux
else
install_vimplus_on_linux
fi
elif [ ${type} == "Darwin" ]; then
install_vimplus_on_mac
else
echo "Not support platform type: "${type}
fi
end=`get_now_timestamp`
second=`expr ${end} - ${begin}`
min=`expr ${second} / 60`
echo "It takes "${min}" minutes."
}
main