-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathinstall.sh
executable file
·66 lines (56 loc) · 1.24 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
63
64
65
66
#!/bin/bash
TIMESTAMP=`date "+%Y-%m-%d-%H:%M:%S"`
VIMRC=${HOME}/.vimrc
VIMRC_BAK=${HOME}/.vimrc-$TIMESTAMP
VIMRC_LOCAL=${PWD}/_vimrc
GVIMRC=${HOME}/.gvimrc
GVIMRC_BAK=${HOME}/.gvimrc-$TIMESTAMP
GVIMRC_LOCAL=${PWD}/_gvimrc
VIM_FOLDER=${HOME}/.vim
VIM_FOLDER_BAK=$VIM_FOLDER-$TIMESTAMP
VIM_FOLDER_LOCAL=${PWD}
RED="\033[0;31m"
LIGHT_BLUE="\033[1;34m"
NC="\033[0m"
echo -e "${LIGHT_BLUE}Start install vim settings....$NC"
backup_file () {
echo -e "${RED}${1} is already exist!${NC}"
read -p "Would you like to backup ${1}? [y/n]" ANS
if [ "$ANS" == "y" ]; then
echo "Backup original ${1} to ${2}"
mv ${1} ${2}
else
echo -e "${LIGHT_BLUE}Bye!${NC}"
exit
fi
}
file_check () {
if [ -L ${1} ] || [ -f ${1} ]; then
backup_file ${1} ${2}
fi
}
folder_check () {
if [ -d ${1} ]; then
backup_file ${1} ${2}
fi
}
install_files() {
ln -sf ${VIM_FOLDER_LOCAL} ${VIM_FOLDER}
ln -sf ${VIMRC_LOCAL} ${VIMRC}
ln -sf ${GVIMRC_LOCAL} ${GVIMRC}
cd ${VIM_FOLDER}
echo -e "${LIGHT_BLUE}Done!${NC}"
}
if [ "${1}" == "-f" ]
then
for ITEM in ${VIM_FOLDER} ${VIMRC} ${GVIMRC}
do
rm -rf ${ITEM}
done
install_files
else
folder_check ${VIM_FOLDER} ${VIM_FOLDER_BAK}
file_check ${VIMRC} ${VIMRC_BAK}
file_check ${GVIMRC} ${GVIMRC_BAK}
install_files
fi