-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbundle.sh
114 lines (91 loc) · 2.34 KB
/
bundle.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env bash
#
# Bundle installation for vconf
VERSION="0.3"
if [ $# -lt 1 ]; then
echo -e "vConf $VERSION installer"
echo -e "Usage: ./bundle.sh install | uninstall "
exit 0;
fi
# Public - Install vim from this bundle
function install_vim() {
echo -e "vconf $VERSION manager\n"
echo -e "[*] Starting the installation"
# Check if git is installed
if which git >/dev/null 2>&1 ; then
echo "[*] Git is installed, proceeding"
else
echo "Error: Git is needed,please install it"
exit 1
fi
if [ -L "$HOME/.vimrc" ]; then
rm -f $HOME/.vimrc
fi
if [ -f "~/.vimrc" ]; then
echo -e "[*] Found existing .vimrc - moving to ~/.vimrc.bak"
mv ~/.vimrc ~/.vimrc.bak
fi
if [ -L "$HOME/.vim" ]; then
rm -f $HOME/.vim
fi
if [ -d "$HOME/.vim/" ]; then
echo -e "[*] Found existing .vim directory - moving to ~/.vim.bak"
mv ~/.vim/ ~/.vim.bak/
fi
echo -e "[*] Linking $PWD/vim/ directory to home"
ln -s $PWD/vim ~/.vim
echo -e "[*] Creating directories for backup, undo and swap"
if [ ! -d "~/.vim/backup/" ]; then
mkdir ~/.vim/backup
fi
if [ ! -d "~/.vim/undo/" ]; then
mkdir ~/.vim/undo
fi
if [ ! -d "~/.vim/_swap/" ]; then
mkdir ~/.vim/_swap/
fi
echo -e "[*] Linking $PWD/.vimrc file to home"
ln -s $PWD/vimrc ~/.vimrc
echo -e "[*] Getting vundle installed"
if [ ! -d "~/.vim/bundle/" ]; then
mkdir ~/.vim/bundle/
fi
# Install Plug
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
if which ruby > /dev/null 2>&1; then
gem install rubocop --no-ri --no-rdoc
else
echo "Ruby not detected on this system, rubocop gem not installed"
fi
echo -e "Starting Vim and installing bundles"
vim +PlugInstall +qall
}
function uninstall_vim() {
echo -e "vconf $VERSION manager"
echo -e "[*] Uninstallation started"
if [ -f "~/.vimrc.old" ]; then
echo -e "[*] Moving back old .vimrc"
rm -f ~/.vimrc
mv ~/.vimrc.bak ~/.vimrc
OLD=1
fi
if [ -d "~/.vim/" ]; then
echo -e "[*] Moving back old .vim directory"
rm -rf ~/.vim/
mv ~/.vim.bak ~/.vim
OLD=1
fi
if [ "$OLD" == "1" ]; then
echo -e "Removing .vim and .vimrc "
rm -rf ~/.vim/ ~/.vimrc
fi
}
case "$1" in
install)
install_vim
;;
uninstall)
uninstall_vim
;;
esac