-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·467 lines (405 loc) · 13.8 KB
/
install.sh
File metadata and controls
executable file
·467 lines (405 loc) · 13.8 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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
#!/bin/bash
installYouCompleteMe=0
while true; do
if [ "x$1" == "x" ];then
break;
fi
case "$1" in
-p | --vimPlugin ) installVimPlugin=1; shift 1 ;;
-d | --debug ) DEBUG=true; shift 1 ;;
-j | --jave ) JAVA=true; shift 1 ;;
--installVim ) INSTALL_VIM=true; shift 1 ;;
--installJava ) INSTALL_JAVA=true; shift 1 ;;
--javaImp ) JAVAIMP=true; shift 1 ;;
--ctags ) CTAGS=true; shift 1 ;;
--installNode ) INSTALL_NODE=true; shift 1 ;;
-ujc | --updateJaveConfig ) UPDATE_JAVA_CONFIG=true; shift 1 ;;
-k | --docker) DOCKER=true; shift 1;;
-i | --init) INIT=true; installVimPlugin=1; shift 1;;
--autoComplete) installYouCompleteMe=1; shift 1;;
--cf) enableCustFont=1; shift 1;;
-f | --fzf) installFZF=1; shift 1;;
--tmux) installTmux=1; shift 1;;
-b | --bashIt) installBashIt=1; shift 1;;
--host) remoteHost=$2; shift 2;;
-h | --help )
echo "Usage:"
echo "-p: install docfiles and vim plugin"
echo "-k: install docker alias"
echo "-j: install docfiles and some vim plugins for java, eclipse"
echo "-i: install docfiles and vim plugins"
echo "--host: install dotfiles to remote host."
shift 1
exit 1
;;
--) echo "-- is not a correct option.";shift 1; ;;
* ) echo "$1 is not a correct option.";shift 1; ;;
esac
done
source ./bin/installWget.sh
custEnvList="enableCustFont"
custEnvList=(${custEnvList// / });
custEnvFile="$HOME/.custEnv"
declare -a custEnv
if [ ! -f $custEnvFile ]; then
touch $custEnvFile
else
i=0;
while read line
do
if [ ! -z $line ] && [ $line != "-e" ];then
s=(${line//=/ });
custEnv[${s[0]}]="${s[1]}"
fi
i=$(( $i + 1 ))
done < $custEnvFile
fi
if [ "x" != "x$remoteHost" ]; then
echo "Sync dotfiles to remote host $remoteHost"
scp basic/alias basic/alias_common \
basic/.bash_common basic/.bash_profile basic/.inputrc \
basic/.bashrc bin/exec.sh basic/.vimrc basic/.vimrc_plugins basic/.vimrc_keymaps basic/.vimrc_lib \
ssh $remoteHost " \
sudo mv exec.sh /usr/local/bin/myExec.sh; mkdir -p ~/.vim/plugged/vim-snipmate/snippets/; \
if [ ! -f ~/.vim/autoload/plug.vim ]; then \
curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim; \
fi"
scp vim-snipmate/*.snippets $remoteHost:~/.vim/plugged/vim-snipmate/snippets/
scp -r vim/colors vim/autoload vim/plugin $remoteHost:~/.vim/
scp -r ~/.vim/plugged $remoteHost:~/.vim/
exit 1
fi
# Remove legacy
rm -f ~/.vim/.vimrc_pluginSettings
rm -rf ~/.sh_tool/z/
touch ~/.bash_host
cp config/coc-settings.json ~/.vim/
cp config/coc-settings.json ~/.config/nvim/
mkdir -p ~/gradle_user_home
#
# Copy all dotfiles
#
files=($(ls basic))
for(( i=0; i<${#files[@]}; i++ ))
do
file=basic/${files[i]}
newFile=".${files[i]}"
echo "copy $file to $newFile"
cp $file ~/$newFile
done
mkdir -p ~/.config/nvim/ ~/vim_gradle
cp nvim/init.vim ~/.config/nvim/
pwd=`pwd`
if hash sudo 2>/dev/null; then
sudo="sudo "
else
sudo=""
fi
# .vim style
eclipseHome=$HOME/.vim/eclipse
if [[ `uname` == 'Darwin' ]]; then
cp -R vim/ ~/.vim
eclipseHome=$HOME/.vim/Eclipse.app/Contents/Eclipse
if [ ! -f /usr/local/opt/coreutils/libexec/gnubin/ls ] && [ ! -f /opt/homebrew/opt/coreutils/libexec/gnubin/ls ];then
brew install coreutils
fi
else
cp -rT vim ~/.vim
fi
echo $DOCKER
if [ "x$DOCKER" == "x" ];then
echo "Without docker"
rm -f ~/.alias_docker
else
if [ -d /usr/local/bin/ ]; then
sudo cp bin/docker_php /usr/local/bin/php
sudo cp bin/docker_php7 /usr/local/bin/php7
sudo cp bin/docker_php7_composer /usr/local/bin/php7_composer
sudo chmod 755 /usr/local/bin/php /usr/local/bin/php7 /usr/local/bin/php7_composer
fi
fi
# ------------------
# Install My command
# ------------------
sudo cp bin/exec.sh /usr/local/bin/myExec.sh
sudo mkdir -p /usr/local/bin/puritys/
sudo cp bin/*.pl /usr/local/bin/puritys/
sudo cp bin/*.sh /usr/local/bin/puritys/
sudo cp bin/appendJavaClasspath.sh /usr/local/bin/
installTmux () {
if [ "x" != "x`command -v yum`" ]; then
sudo yum install -y screen tmux
## install the latest tmux
version=3.0
sudo yum install -y gcc kernel-devel make ncurses-devel libevent-devel
wget https://github.com/tmux/tmux/releases/download/$version/tmux-$version.tar.gz
tar -xvzf tmux-$version.tar.gz
cd tmux-$version
LDFLAGS="-L/usr/local/lib -Wl,-rpath=/usr/local/lib" ./configure --prefix=/usr/
make
sudo make install
rm -rf tmux*
cd -
elif [[ `uname` == 'Darwin' ]]; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" < /dev/null 2> /dev/null
brew install tmux
fi
}
installFzf () {
if [ ! -d ~/.sh_tool ]; then
mkdir ~/.sh_tool
git clone --depth 1 git@github.com:junegunn/fzf.git ~/.sh_tool/fzf
~/.sh_tool/fzf/install --all
## append
# <(cat ~/machine_list.txt | command grep -v '#' | sed -e 's/^/host /') \
# to ~/.sh_tool/fzf/shell/completion.bash : _fzf_complete_ssh
### new version of fzf
# ~/.vim/plugged/fzf/shell/completion.bash
fi
if [ ! -d ~/.sh_tool/clvv-fasd-4822024 ]; then
# ------------
# Install fasd cd
# ------------
cd ~/.sh_tool/ ; wget https://github.com/clvv/fasd/tarball/1.0.1
tar -zxvf 1.0.1
cd -
cd ~/.sh_tool/clvv-fasd-4822024; PREFIX=$HOME make install
sudo cp fasd /usr/local/bin/
sudo chmod 755 /usr/local/bin/fasd
cd -
fi
}
installAg() {
echo -e "Install ag \n"
if [ "x" == "x`command -v /usr/local/bin/ag`" ]; then
installedAg=0
if [ -f /etc/redhat-release ]; then
v=`cat /etc/redhat-release`
if [[ "$v" == *"7."* ]]; then
resp=`sudo yum install -y the_silver_searcher 2>&1`
if [[ $resp == *"Nothing to do"* ]]; then
echo "could not use yum to install silver search"
else
installedAg=1
fi
fi
elif [[ `uname` == 'Darwin' ]]; then
brew install the_silver_searcher
installedAg=1;
fi
if [ "x0" == "x$installedAg" ] && [ "x" != "x`command -v yum`" ];then
sudo yum install automake pcre-devel xz-devel zlib-devel -y
echo "current pwd = `pwd`"
if [ ! -d the_silver_searcher ]; then
git clone https://github.com/ggreer/the_silver_searcher.git
fi
cd the_silver_searcher
./build.sh
make
sudo make install
cd -
fi
fi
}
installVim () {
wget https://github.com/vim/vim/archive/v8.1.1317.tar.gz
tar -zxvf v8.1.1317.tar.gz
mv vim-8.1.1317 vim_src;
cd vim_src
./configure --enable-multibyte --enable-pythoninterp=yes --prefix=/usr; \
gmake
sudo gmake install
cd -
rm -rf v8*.gz
}
if [ ! -d /tmp/fzf_session ]; then
mkdir -p /tmp/fzf_session
fi
# Install youCompleteMe
if [ "x$installYouCompleteMe" == "x1" ]; then
if [ ! -d ~/.vim/plugged/YouCompleteMe ]; then
echo "Install YouCompleteMe: need cmake and python-devel-2.7 or 3 "
if [ -f /usr/bin/yum ];then
sudo yum -y install cmake python-devel
# sudo yum -y install https://centos7.iuscommunity.org/ius-release.rpm
# sudo yum install build-essential cmake python-devel python3-devel
fi
git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/plugged/YouCompleteMe
cd ~/.vim/plugged/YouCompleteMe
git submodule update --init --recursive
python2 ./install.py --clang-completer # or --all --clang-completer --gocode-completer --java-completer
cd -
fi
fi
# Install vim Plugin
if [ "x$installVimPlugin" != "x" ];then
if [ -d ~/.vim/bundle ]; then
$sudo rm -rf ~/.vim/bundle
$sudo rm -rf ~/.vim/.vimrc_vundle
fi
if [ "x" == "x`command -v npm`" ]; then
sudo dnf install npm -y
fi
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
sudo rm -rf ~/.vim/plugged/vim-snipmate/
echo "\n" | vim -c :PlugInstall +qall
# install coc plugin
if [ "x" != "x`command -v npm`" ]; then
mkdir -p ~/.config/coc/extensions;
sudo chmod -R 755 ~/.config/coc/extensions;
if [ `arch` == "aarch64" ]; then
# coc-tabnine not support apple M1 cpu(arm64)
cocPlugins=""
else
cocPlugins="coc-tabnine"
fi
cd ~/.config/coc/extensions;
npm init -y
# coc-groovy
npm install coc-highlight coc-lists coc-pairs coc-xml $cocPlugins coc-snippets coc-java coc-kotlin coc-tsserver coc-eslint coc-go coc-word coc-phpls coc-pyright coc-json coc-prettier coc-sql coc-flutter --global-style --ignore-scripts --no-bin-links --only=prod;
# install java decompiler
echo "\n" | vim -c :CocInstall https://github.com/dgileadi/vscode-java-decompiler +qall
# Manually download tabnine and fix permission
# - https://update.tabnine.com/bundles/3.7.5/x86_64-unknown-linux-musl/TabNine.zip
# - sudo chmod -R 755 ~/.config/coc/extensions/coc-tabnine-data/
cd -
fi
pip=`command -v pip3`
if [ -f $pip ]; then
pip3 install pynvim
fi
# ALE fixer:
sudo npm install -g fixjson
fi
# Update snippet script
if [ ! -d ~/.vim/plugged/vim-snipmate/snippets ]; then
mkdir -p ~/.vim/plugged/vim-snipmate/snippets
fi
$sudo rm -f ~/.vim/plugged/vim-snipmate/snippets/*
cp vim-snipmate/*.snippets ~/.vim/plugged/vim-snipmate/snippets/
if [ -d /usr/local/lib/ ]; then
# install google java code format
if [ ! -f /usr/local/lib/google-java-format-1.4-all-deps.jar ]; then
sudo cp vim/javaPlugin/google-java-format-1.4-all-deps.jar /usr/local/lib/
fi
if [ ! -f /usr/local/lib/lombok.jar ]; then
# install lombok for coc-java
wget https://projectlombok.org/downloads/lombok.jar
sudo mv lombok.jar /usr/local/lib/
fi
fi
# install JavaImp
# http://www.vim.org/scripts/script.php?script_id=325
# Java JDK https://github.com/AdoptOpenJDK/openjdk-jdk11/archive/refs/tags/jdk-11+28.zip
downloadOpenJdk=0
if [ "x$JAVA" != "x" ] && [ ! -d "$HOME/openjdk/classes" ]; then
downloadOpenJdk=1
fi
if [ "x$JAVAIMP" != "x" ] && [ ! -d "$HOME/openjdk/classes" ]; then
downloadOpenJdk=1
fi
if [ "x$downloadOpenJdk" == "x1" ]; then
if [ "x" != "x`command -v yum`" ]; then
sudo yum install unzip -y
fi
if [ ! -f "jdk-11+28.zip" ]; then
wget https://github.com/AdoptOpenJDK/openjdk-jdk11/archive/refs/tags/jdk-11+28.zip
fi
mkdir ~/.vim/JavaImp
cp config/JavaImp/* ~/.vim/JavaImp/
mkdir ~/openjdk
mv jdk-11+28.zip ~/openjdk/
cd ~/openjdk
unzip jdk-11+28.zip
mv openjdk-jdk11-jdk-11-28/src ./classes
rm -rf openjdk-jdk11-jdk-11-28
rm jdk-11+28.zip
cd -
fi
if [ -d ~/.vim/JavaImp/ ];then
cp config/JavaImp/* ~/.vim/JavaImp/
fi
# JAVA settings
if [ ! -d "$HOME/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/" ];then
mkdir -p $HOME/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/;
fi
cp vim/javaPlugin/eclipse_config/*.sh ~/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings/
pwd2="$HOME/workspace/.metadata/.plugins/org.eclipse.core.runtime/.settings"
sh $pwd2/org.eclipse.jdt.core.prefs.sh > $pwd2/org.eclipse.jdt.core.prefs
sh $pwd2/org.eclipse.jdt.apt.core.prefs.sh > $pwd2/org.eclipse.jdt.apt.core.prefs
sudo mkdir -p /usr/local/etc/
sudo cp vim/javaPlugin/google_checks.xml /usr/local/etc/
sudo cp vim/javaPlugin/checkstyle.xml /usr/local/etc/
source ./scripts/installCommonCommand.sh
if [ "x$installFZF" != "x" ]; then
installFzf
fi
if [ "x$INIT" != "x" ]; then
## Basic package
installFzf
installTmux
installAg
fi
if [ "x$installBashIt" != "x" ]; then
# ------------
# Install bash-it
# ------------
git clone --depth=1 git@github.com:Bash-it/bash-it.git ~/.bash_it
~/.bash_it/install.sh --no-modify-config --silent
export BASH_IT="$HOME/.bash_it"
source "$BASH_IT"/bash_it.sh
complete="bash-it,defaults,dirs,docker,virtualbox,ssh,pip,pip3,makefile,git,git_flow,docker-machine,brew,export,maven,npm"
complete=(${complete//,/ });
for(( i=0; i<${#complete[@]}; i++ ))
do
line=${complete[$i]}
bash-it enable completion $line
done
plugin="ssh,dirs,java,node"
plugin=(${plugin//,/ });
for(( i=0; i<${#plugin[@]}; i++ ))
do
line=${plugin[$i]}
bash-it enable plugin $line
done
bash-it disable alias all
fi
# -------------------------------
# Install ctags for auto complete
# -------------------------------
if [ "x" != "x$CTAGS" ]; then
if [ "x" != "x`command -v yum`" ]; then
sudo yum install -y ctags
fi
if [ -d /www ];then
cd /www
ctags -R --fields=+laimS --languages=php -f ~/.vim/php_tags -a
cd -
fi
cd ~/
ctags -R --fields=+laimS --languages=php -f ~/.vim/php_tags -a
cd -
fi
if [ ! -z $enableCustFont ]; then
custEnv["enableCustFont"]="1"
fi
if [ ! -z $INSTALL_VIM ] && [ true == "$INSTALL_VIM" ];then
installVim
fi
if [ 1 == "$installTmux" ];then
installTmux
fi
content=""
for key in "${custEnvList[@]}"
do
if [ ! -z ${custEnv[$key]} ]; then
content="\n$key=${custEnv[$key]}"
fi
done
OS=$(uname -s)
if [[ X"$OS" == X"Darwin" ]]; then
echo $content > $custEnvFile
else
echo -e $content > $custEnvFile
fi