-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildZYEVN.sh
executable file
·151 lines (135 loc) · 3.86 KB
/
buildZYEVN.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
#!/bin/bash
function verbose()
{
local type=$1
local info=$2
local tips=$3
local color=$GREEN
local time=`date "+%Y/%m/%d %T.%3N"`
[[ x"$tips" != x"" ]] && tips="H"
case $type in
ERROR) eval color=\$${tips}RED ;;
WARN) eval color=\$${tips}YELLOW ;;
INFO) eval color=\$${tips}GREEN ;;
esac
echo -e "${color}$time [$type] $info${NC}"
}
function installSIMAPP()
{
local appName="$1"
sudo apt install $appName
if [ $? -ne 0 ]; then
verbose WARN "Install $appName failed!"
return 1
fi
return 0
}
function installZVIM()
{
verbose INFO "Installing zvim..."
local makefailed=false
local vimdir=~/tools/vim
if [ ! -e "$pyconfdir" ]; then
if [ ! -e "$pyconfdirBak" ] then
pyconfdir=$pyconfdirBak
else
verbose WARN "No available python! Some advanced function cannot be used!"
installSIMAPP "vim"
fi
fi
mkdir -p ~/tools
git clone [email protected]:vim/vim.git ~/tools
cd $vimdir
sudo ./configure --with-features=huge --enable-pythoninterp --enable-rubyinterp --enable-luainterp --enable-perlinterp --with-python-config-dir=$pyconfdir --enable-gui=gtk2 --enable-cscope --prefix=/usr &>/dev/null
if [ $? -ne 0 ]; then
verbose WARN "Configure origin vim failed!" H
makefailed=true
else
sudo make &>/dev/null
if [ $? -ne 0 ]; then
verbose WARN "Make origin vim failed!" H
makefailed=true
else
sudo make install &>/dev/null
if [ $? -ne 0 ]; then
verbose WARN "Make install origin vim failed!" H
makefailed=true
fi
fi
fi
cd -
[[ $makefailed = "true" ]] && installSIMAPP "vim"
verbose INFO "Downloading vim configure..."
if [ -e "$zvimFile" ]; then
rm $zvimFile
fi
wget https://raw.githubusercontent.com/TonyCode2012/configuration/master/.zvimrc -P ~/
if [ $? -ne 0 ]; then
verbose ERROR "Download failed!" H
exit 1
fi
verbose INFO "Downloading vim bundles..."
cat $zvimFile | grep '^Plugin' | while read line; do
repo=`echo $line | grep -Po "(?<=\').*(?=\')"`
echo -n "[INFO] Collecting $repo"
git clone https://github.com/$repo $bundledir &>/dev/null
if [ $? -ne 0 ]; then
echo " [WARN] Download failed!" H
else
echo " done."
fi
done
verbose INFO "Installing ctags..."
installsimapp "ctags"
verbose INFO "Installing ag..."
installSIMAPP "silversearcher-ag"
}
function installTMUX()
{
verbose INFO "Installing tmux..."
installSIMAPP "tmux"
verbose INFO "Downloading tmux configure..."
local tmuxFile=~/.tmux.conf
if [ -e "$tmuxFile" ]; then
rm $tmuxFile
fi
wget -P ~/ https://raw.githubusercontent.com/TonyCode2012/configuration/master/.tmux.conf
}
############### MAIN BODY ###############
RED='\033[0;31m'
HRED='\033[1;31m'
GREEN='\033[0;32m'
HGREEN='\033[1;32m'
YELLOW='\033[0;33m'
HYELLOW='\033[1;33m'
NC='\033[0m'
VIMHOME=~/.vim
bundledir=$VIMHOME/bundle
zvimFile=~/.zvimrc
pyconfdir=/usr/lib/python2.7/config
pyconfdirBak=/usr/lib/python2.7/config-x86_64-linux-gnu
if [ ! -e "$bundledir" ]; then
mkdir -p $bundledir
fi
### vim related
installZVIM
### tmux related
installTMUX
### add zvim to alias {{{
verbose INFO "Adding alias in .bashrc..."
bashFile=~/.bashrc
if grep zvim $bashFile &>/dev/null; then
exit 0
fi
if ! grep "alias" $bashFile &>/dev/null; then
aline=`wc -l $bashFile | awk '{print $1}'`
else
aline=`grep -rin "^alias" $bashFile | tail -n 1 | while read line; do line=${line%%:*}; echo $line; done`
fi
if [[ ! $aline =~ ^[0-9]+$ ]]; then
verbose ERROR "Find alias line failed!" H
exit 1
fi
sed -i "$aline aalias zvim='vim -u ~/.zvimrc'" $bashFile;
source $bashFile
### }}}