-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·64 lines (56 loc) · 1.4 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
#!/bin/bash
# refer spf13-vim bootstrap.sh`
BASEDIR=$(dirname $0)
cd $BASEDIR
CURRENT_DIR=`pwd`
# parse arguments
function show_help
{
echo "install.sh [option]
--for-vim Install configuration files for vim, default option
--help Show help messages
For example:
install.sh --for-vim
install.sh --help"
}
FOR_VIM=true
if [ "$1" != "" ]; then
case $1 in
--for-vim)
FOR_VIM=true
shift
;;
*)
show_help
exit
;;
esac
fi
lnif() {
if [ -e "$1" ]; then
ln -sf "$1" "$2"
fi
}
echo "Step1: backing up current vim config"
today=`date +%Y%m%d`
if $FOR_VIM; then
for i in $HOME/.vim $HOME/.vimrc $HOME/.gvimrc $HOME/.vimrc.bundles; do [ -e $i ] && [ ! -L $i ] && mv $i $i.$today; done
for i in $HOME/.vim $HOME/.vimrc $HOME/.gvimrc $HOME/.vimrc.bundles; do [ -L $i ] && unlink $i ; done
fi
echo "Step2: setting up symlinks"
if $FOR_VIM; then
lnif $CURRENT_DIR/vimrc $HOME/.vimrc
lnif $CURRENT_DIR/vimrc.bundles $HOME/.vimrc.bundles
lnif "$CURRENT_DIR/" "$HOME/.vim"
fi
echo "Step3: update/install plugins using Vim-plug"
system_shell=$SHELL
export SHELL="/bin/sh"
if $FOR_VIM; then
vim -u $HOME/.vimrc.bundles +PlugInstall! +PlugClean! +qall
else
nvim -u $HOME/.vimrc.bundles +PlugInstall! +PlugClean! +qall
fi
export SHELL=$system_shell
echo "Install Done!"
exit 0