-
Notifications
You must be signed in to change notification settings - Fork 26
/
setup.sh
52 lines (40 loc) · 1.14 KB
/
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
45
46
47
48
49
50
51
52
#!/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/"
}
function install_bundle() {
exe_cmd 'rm -rf ~/.vim/bundle'
exe_cmd 'mkdir -p ~/.vim/bundle'
exe_cmd 'git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim'
exe_cmd 'vim +PluginInstall +qall'
}
backup_and_clean
copy_new_config
install_bundle