-
Notifications
You must be signed in to change notification settings - Fork 2
/
install_vim.sh
executable file
·57 lines (47 loc) · 1.1 KB
/
install_vim.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
#!/bin/bash
set -eu
# ========
# Defaults
# ========
REPO_ADDRESS=${REPO_ADDRESS:-'https://github.com/holser/dotfiles.git'}
VIM_DIR=${VIM_DIR:-~/.vim}
VIMRC=${VIMRC:-~/.vimrc}
GIT=${GIT:-'git'}
VIM=${VIM_EXECUTABLE:-'vim'}
function link_file {
source="${PWD}/$1"
target="${HOME}/$1"
if [ -f "${target}" ]; then
mv ${target}{,.$(date +%F).bak}
fi
ln -sf ${source} ${target}
}
function check_binary {
if [ -z $1 ]; then
echo "No arguments found"
exit 1
fi
if ! command -v $1; then
echo "$1 was not found. Please install it"
fi
}
check_binary $VIM
check_binary $GIT
check_binary curl
if [ -d ~/.dotfiles ]; then
pushd ~/.dotfiles/
${GIT} pull origin master
popd
else
${GIT} clone ${REPO_ADDRESS} ~/.dotfiles
fi
# Install vim-plug
curl -fLo ${VIM_DIR}/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
pushd ~/.dotfiles
link_file .vimrc
for file in .vim/*.vim; do
link_file ${file} ${VIM_DIR}
done
popd
${VIM} -u ~/.dotfiles/.vimrc +PlugInstall! +PlugUpdate! +PlugClean! +qall