This repository has been archived by the owner on May 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·116 lines (91 loc) · 2.21 KB
/
install
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
115
116
#!/usr/bin/env bash
# Colors
COL_BLUE="\x1b[36;01m"
COL_GREEN="\x1b[32;01m"
COL_RESET="\x1b[39;49;00m"
COL_RED="\x1b[31;01m"
VIM_DIR=$HOME/.vim
# Helper functions
_print() {
printf $COL_BLUE"\n$1\n"$COL_RESET
}
_error() {
printf $COL_RED"\n\t[Error] $1\n"$COL_RESET
}
_success() {
printf $COL_GREEN"\n\t$1\n"$COL_RESET
}
_usage() {
_print " Usage: install [-ah]
Options:
-h Show this message
-m Install MacVim through homebrew first, then setup vim config
"
exit 0
}
have() {
type "$1" &> /dev/null
}
#############################################################################
_install_macvim() {
# MacVim
_print "Installing MacVim with homebrew (don't worry, won't install twice)"
echo `sudo mv /usr/bin/vim /usr/bin/vim.osx` > /dev/null
brew install macvim --override-system-vim
}
_install() {
# check for fzf
if ! [ -x "$(command -v git)" ]; then
_print "Installing fzf"
brew install fzf
exit 1
fi
# Vim plug
_print "Installing Vim Plug"
if [ -f "$VIM_DIR/autoload/plug.vim" ] ; then
_success "Vim Plug is already installed"
else
curl -fLo $VIM_DIR/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
curdir=$(pwd)
# Backup vimrc if exists
if [ -f "$HOME/.vimrc" ] || [ -L "$HOME/.vimrc" ] ; then
mv "$HOME/.vimrc" "$HOME/.vimrc.backup"
fi
# Symlink new vimrc
ln -s $VIM_DIR/vimrc ~/.vimrc
if have nvim; then
_print "Installing python (for neovim)"
pip2 install --user neovim
pip3 install --user neovim
fi
_print "Install plugins"
vim +PlugInstall +qall
_success "Ready to rock!"
_print "* Reload your shell for maximum effect *"
# output something to see we installed vim
echo 1 > '.vim-installed'
}
#############################################################################
if [ $# -eq 0 ]; then
_print "Installing"
_install
fi
#############################################################################
# parse arguments
while getopts :hma opt; do
case $opt in
m)
_install_macvim
_install
;;
h)
_usage
;;
*)
_error "Invalid option received"
_usage
exit 0
;;
esac
done