-
Notifications
You must be signed in to change notification settings - Fork 26
/
fast-setup.sh
44 lines (34 loc) · 948 Bytes
/
fast-setup.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
#!/bin/bash
__root_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
vim_config_dir=$HOME/.vim
vim_rc=$HOME/.vimrc
function exe_cmd() {
echo $1
eval $1
}
function ensure_dir() {
if [ ! -d $1 ]; then
exe_cmd "mkdir -p $1"
fi
}
function backup_and_clean() {
local d=`date +%Y%m%d-%H%M%S`
local backup_dir="$HOME/.vimbackup/${d}"
ensure_dir $backup_dir
if [ -e $vim_rc ]; then
exe_cmd "mv $vim_rc $backup_dir/.vimrc"
fi
if [ -e $vim_config_dir ]; then
exe_cmd "cp -R $vim_config_dir $backup_dir/.vim"
exe_cmd "rm -rf $vim_config_dir"
fi
}
function copy_new_config() {
exe_cmd "cp $__root_dir/files/_vimrc $vim_rc"
ensure_dir $vim_config_dir
exe_cmd "cp -R $__root_dir/files/vimfiles/* $vim_config_dir/"
exe_cmd "cp -R $__root_dir/3rd/bundle $vim_config_dir/"
}
backup_and_clean
copy_new_config
exe_cmd 'vim +PluginInstall +qall'