-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_vim.sh
executable file
·45 lines (34 loc) · 997 Bytes
/
setup_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
#!/usr/bin/env bash
# Basic setup
# TODO: add some command line options to make this more versatile
# Generic function to handle prompting the user
# This should be used for all verification interactions with the user
prompt() {
echo "$1"
read -rp "Do you want to continue? [y/n]" yes_or_no
if [ "$yes_or_no" = "n" ]; then
echo "NOTICE: Exiting"
exit 0
fi
return 0
}
# Update files
git fetch
git pull origin master
if [ -d ~/.vim ]; then
status=$(prompt "NOTICE: Found pre-existing vim directory at ~/.vim")
if [ "$status" -eq "0" ]; then
echo "NOTICE: Overwriting vim directory at ~/.vim"
rm -rf ~/.vim
fi
fi
# Copy files over
cp -r .vim/ ~/
if [ -e ~/.vimrc ]; then
echo "NOTICE: Found pre-existing vimrc at ~/.vimrc; removing"
rm -f ~/.vimrc
fi
# Link file(s)
ln -s ~/.vim/.vimrc ~/.vimrc
echo "NOTICE: Updated and linked vimrc"
prompt "NOTICE: There are vim plugins that can be installed" && vim +PlugInstall