-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathinstall.sh
executable file
·62 lines (52 loc) · 1.66 KB
/
install.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
#!/bin/bash
# Yanan Zhao, 2016
UPDATE_PLUGINS=0
print_help() {
echo "Usage: $0 [Options]"
echo "Options:"
echo " -h/--help print this help message and exit"
echo " -u/--update-plugins use lasted plugins on install. Default false."
echo " NOTE this may be time-consuming as it will"
echo " pull the plugins from github"
}
if [ $# -eq 1 ]; then
if [[ $1 = "-h" || $1 = "--help" ]]; then
print_help
exit 1
elif [[ $1 = "-u" || $1 = "--update-plugins" ]]; then
echo "update plugins: true"
UPDATE_PLUGINS=1
else
echo "unkown options: $@"
fi
fi
# step.1. backup your old configurations
echo -e "\033[36m[1] backing up current configurations ...\033[0m"
# with two leading dots to distinguish it from vim configuration files
BACKUP_DIR=$HOME/..vimback
if [ -d $BACKUP_DIR ]; then
echo -e "$BACKUP_DIR already exists, refresh it"
rm -rf $BACKUP_DIR
fi
mkdir $BACKUP_DIR
mv $HOME/.vim* $BACKUP_DIR
echo -e "\033[34mbackup successful\033[0m"
echo -e ""
# step.2. update plugins
echo -e "\033[36m[2] updating plugins ...\033[0m"
if [ $UPDATE_PLUGINS -eq 1 ]; then
# $SRC_DIR/update_plugins.py
# if [ $? -gt 0 ]; then
# echo -e "\033[31minstall abort\033[0m"
# exit 1
# fi
echo -e "\033[34mupdate successful\033[0m"
else
echo -e "\033[34mskip updating plugins as -u/--update-plugins not specified\033[0m"
fi
echo -e ""
# step.3. install
echo -e "\033[36m[3] install new configurations ...\033[0m"
cp -rf vim_runtime $HOME/.vim_runtime
cp -rf vimrc $HOME/.vimrc
echo -e "\033[34minstall successful, enjoy it :-)\033[0m"