-
-
Notifications
You must be signed in to change notification settings - Fork 130
/
install
executable file
·129 lines (114 loc) · 3.75 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
#!/usr/bin/env bash
# Reset
Color_off='\033[0m' # Text Reset
# Regular Colors
Red='\033[0;31m' # Red
Blue='\033[0;34m' # Blue
Version='0.1.0'
echo 'Welcome to VimWeb, a powerful & modern vim distribution'
echo 'Booting VimWeb ...'
# 生成 .vim 文件夹
# [[ -d ~/.vim ]] || mkdir ~/.vim;
# tmp dir
# [[ -d ~/VimWeb ]] || mkdir ~/VimWeb;
# .vimrc
# cd ~/VimWeb;
# [[ -d ~/VimWeb/rc ]] || git clone https://github.com/jaywcjlove/vim-web.git;
install_vim () {
if [[ -d "$HOME/.vim" ]]; then
if [[ "$(readlink $HOME/.vim)" =~ \.VimWeb$ ]]; then
echo -e "${Blue}Installed VimWeb for vim${Color_off}"
else
mv "$HOME/.vim" "$HOME/.vim_back"
echo -e "${Blue}BackUp $HOME/.vim${Color_off}"
ln -s "$HOME/.VimWeb" "$HOME/.vim"
echo -e "${Blue}Installed VimWeb for vim${Color_off}"
fi
else
ln -s "$HOME/.VimWeb" "$HOME/.vim"
# ln -s "$HOME/.VimWeb/.vimrc" "$HOME/.vimrc"
echo -e "${Blue}Installed VimWeb for vim${Color_off}"
fi
if [[ -d "$HOME/.vimrc" ]]; then
if [[ "$(readlink $HOME/.vimrc)" =~ \.vimrc$ ]]; then
echo -e "${Blue}Installed .vimrc for vim${Color_off}"
else
mv "$HOME/.vimrc" "$HOME/.vimrc_back"
echo -e "${Blue}BackUp $HOME/.vimrc${Color_off}"
ln -s "$HOME/.VimWeb/.vimrc" "$HOME/.vimrc"
echo -e "${Blue}Installed .VimWeb/.vimrc for vim${Color_off}"
fi
else
ln -s "$HOME/.VimWeb/.vimrc" "$HOME/.vimrc"
echo -e "${Blue}Installed .VimWeb/.vimrc for vim${Color_off}"
fi
}
uninstall_vim () {
if [[ -d "$HOME/.vim" ]]; then
if [[ "$(readlink $HOME/.vim)" =~ \.VimWeb$ ]]; then
rm "$HOME/.vim"
echo -e "${Blue}Uninstall VimWeb for vim${Color_off}"
if [[ -d "$HOME/.vim_back" ]]; then
mv "$HOME/.vim_back" "$HOME/.vim"
echo -e "${Blue}Recover $HOME/.vim${Color_off}"
fi
fi
fi
if [[ -f "$HOME/.vimrc_back" ]]; then
mv "$HOME/.vimrc_back" "$HOME/.vimrc"
echo -e "${Blue}Recover $HOME/.vimrc${Color_off}"
fi
}
usage () {
echo " "
echo " VimWeb install script : ${Version}v0.1.0"
echo " "
echo -e " ${Blue}Install VimWeb for vim${Color_off}"
echo " curl -sLf https://raw.githubusercontent.com/jaywcjlove/vim-web/master/install | bash -s -- install"
echo " "
echo -e " ${Blue}Uninstall VimWeb${Color_off}"
echo " curl -sLf https://raw.githubusercontent.com/jaywcjlove/vim-web/master/install | bash -s -- uninstall"
echo " "
}
need_cmd () {
if ! hash "$1" &>/dev/null; then
echo -e "${Red}need '$1' (command not found)${Color_off}"
exit 1
fi
}
fetch_repo () {
if [[ -d "$HOME/.VimWeb" ]]; then
git --git-dir "$HOME/.VimWeb/.git" pull
echo -e "${Blue}Successfully update .VimWeb${Color_off}"
else
git clone https://github.com/jaywcjlove/vim-web.git "$HOME/.VimWeb" --depth=1 --recurse-submodules
echo -e "${Blue}Successfully clone .VimWeb${Color_off}"
fi
curl -LSso ~/.VimWeb/autoload/pathogen.vim https://tpo.pe/pathogen.vim
echo -e "${Blue}Successfully download ~/.VimWeb/autoload/pathogen.vim${Color_off}"
curl -LSso ~/.VimWeb/colors/molokai.vim https://raw.githubusercontent.com/fatih/molokai/master/colors/molokai.vim
echo -e "${Blue}Successfully download ~/.VimWeb/colors/molokai.vim${Color_off}"
}
if [ $# -gt 0 ]
then
case $1 in
uninstall)
uninstall_vim
exit 0
;;
install)
need_cmd 'git'
fetch_repo
install_vim
# echo -e "${Red}need '$1' (command 5 install_vim)${Color_off}"
exit 0
;;
-h)
usage
exit 0
;;
*)
usage
exit 0
esac
fi