-
Notifications
You must be signed in to change notification settings - Fork 112
/
start_vim.sh
executable file
·159 lines (152 loc) · 4.15 KB
/
start_vim.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
#!/bin/bash
#########################################################################
# File Name: start_vim.sh
# Author: meetbill
# mail: [email protected]
# Created Time: Thu 06 Nov 2014 06:31:50 PM CST
# Updated Time: 2018-04-22 14:33
#########################################################################
#Define Path
VIM_PATH=$(cd `dirname $0`; pwd)
cd ${VIM_PATH}
VIMRC=~/.vimrc
VIM_FILE=./packages/vim1*
#{{{vim_orther
function vim_orther()
{
# 判断是否有 git 命令,如果没有 git 命令,则进行清理 vim-gitgutter 目录
Command=git
which $Command > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo $Command is exist
else
echo $Command not exist
git_dir=~/.vim/bundle/vim-gitgutter
[[ -d ${git_dir} ]] && rm -rf ${git_dir}
fi
}
#}}}
#{{{scripts_generic_identifyos
function scripts_generic_identifyOs()
{
## determine OS of computer
os=$(uname -a)
if [[ ${os} == *"Darwin"* ]]; then
os="Mac"
return 0
elif [[ ${os} == *"Ubuntu"* ]]; then
os="Ubuntu"
return 0
fi
if [[ -e "/etc/system-release-cpe" ]]
then
if [[ "$(cat /etc/system-release-cpe)" == *"centos"* ]]; then
os="Centos"
elif [[ "$(cat /etc/system-release-cpe)" == *"redhat"* ]]; then
os="Redhat"
fi
else
os="Unrecognised"
echo "os:${os}"
fi
return 0
}
#}}}
#{{{Vim_config
function Vim_config ()
{
clear
# 输入用户名以及邮箱
read -p "Please input your name:(default:meetbill)" AUTHOR
[[ -z "$AUTHOR" ]] && AUTHOR="meetbill"
read -p "Please input your E-mail:(default:[email protected])" MAIL_AUTHOR
[[ -z "$MAIL_AUTHOR" ]] && MAIL_AUTHOR="[email protected]"
[[ -d ~/.vim ]] && rm -rf ~/.vim
if [ `id -u` -eq 0 ];
then
tar -zxf ${VIM_FILE} -C ~/
cd ./packages/
check_ctags=`ls -l /usr/bin/ | grep ctags|wc -l`
if [[ "w$check_ctags" == "w0" ]]
then
tar -zxf ctags.tar.gz -C /usr/bin/
chmod 755 /usr/bin/ctags
fi
if [[ -e ~/.bashrc ]]
then
CK_VIM=`grep "vi='vim'" ~/.bashrc | wc -l`
if [ "w${CK_VIM}" = "w0" ]
then
echo " " >> ~/.bashrc
echo "alias vi='vim'" >> ~/.bashrc
fi
. ~/.bashrc
fi
else
chmod -R 777 packages
tar -zxf ${VIM_FILE} -C ~/
cd ./packages/
check_ctags=`ls -l /usr/bin/ | grep ctags|wc -l`
if [[ "w$check_ctags" == "w0" ]]
then
sudo tar -zxf ctags.tar.gz -C /usr/bin/
sudo chmod 755 /usr/bin/ctags
fi
if [[ -e ~/.bashrc ]]
then
CK_VIM=`grep "vi='vim'" ~/.bashrc | wc -l`
if [ "w${CK_VIM}" = "w0" ]
then
echo " " >> ~/.bashrc
echo "alias vi='vim'" >> ~/.bashrc
fi
. ~/.bashrc
fi
fi
cd ${VIM_PATH}
cp ./packages/vimrc ~/.vimrc
if [[ "w$os" == "wMac" ]]
then
sed -i "" "s/[email protected]/$MAIL_AUTHOR/g" $VIMRC
sed -i "" "s/meetbill/$AUTHOR/g" $VIMRC
else
sed -i "s/[email protected]/$MAIL_AUTHOR/g" $VIMRC
sed -i "s/meetbill/$AUTHOR/g" $VIMRC
fi
vim_orther
echo "this vim config is success !"
exit 0
}
#}}}
clear
echo " "
echo -e " \033[44;37m========================================================================\033[0m"
echo -e " \033[44;33m|------------------------------Description------------------------------\033[0m"
echo -e " \033[44;37m========================================================================\033[0m"
echo -e " \033[33m \033[0m"
echo -e " \033[33m the confing of vim is for admin\033[0m"
echo -e " \033[33m \033[0m"
echo -e " \033[44;37m=========================================================================\033[0m"
echo " "
echo " "
scripts_generic_identifyOs
echo "OS:"${os}
echo " "
PS3="Please input a number":
select i in "Vim_config" "quit"
do
case $i in
Vim_config )
Vim_config
;;
quit)
exit $?
;;
*)
echo
echo -e "\033[44;37mPlease Insert :Vim_config(1)|Exit(2)\033[0m"
echo
;;
esac
done