-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
executable file
·77 lines (65 loc) · 2.07 KB
/
update.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
#!/usr/bin/env bash
# find out absolute path to ourselves (http://stackoverflow.com/questions/4774054)
pushd `dirname $0` > /dev/null
DOTFILES=`pwd -P`
popd > /dev/null
echo "Switching to $DOTFILES"
cd "$DOTFILES"
git pull origin master;
function doIt() {
# check for vim
if [ ! -e /usr/bin/vim ]; then
echo "No vim found, please install before running update.sh."
exit 1
fi
# check if vim has plugin manager
if [ ! -e $HOME/.vim/autoload/plug.vim ]; then
read -p "No plugin manager found, install vim-plug?" -n 1
if [[ $REPLY =~ ^[Yy]$ ]]; then
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
fi
fi
# TODO: update vim plugins
# check for zsh
if [ ! -e /usr/bin/zsh -a ! -e /bin/sh ]; then
echo "No zsh found, please install before running update.sh."
exit 1
fi
# check for oh-my-zsh
if [ ! -d $HOME/.oh-my-zsh ]; then
read -p "No oh-my-zsh found, install?" -n 1
if [[ $REPLY =~ ^[Yy]$ ]]; then
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
fi
fi
# update home directory
echo -ne "Updating home directory..."
FILES=`find . -maxdepth 1 | grep -vEf exclude`
cd $HOME
for i in $FILES; do
ln -sf "$DOTFILES/$i" .
done
cd "$DOTFILES"
echo "done."
# install setup template, if not present
if [ ! -e $HOME/.localsetup ]; then
echo "Installing per-host setup template. Edit .localsetup to fit your needs."
cp $DOTFILES/.localsetup $HOME/.localsetup
fi
# install vim template, if not present
if [ ! -e $HOME/.localvimrc ]; then
echo "Installing per-host vim template. Edit .localvimrc to fit your needs."
cp $DOTFILES/.localvimrc $HOME/.localvimrc
fi
}
if [ "$1" = "--force" -o "$1" = "-f" ]; then
doIt;
else
read -p "This may overwrite existing files in your home directory. Are you sure? (y/n) " -n 1;
echo "";
if [[ $REPLY =~ ^[Yy]$ ]]; then
doIt;
fi;
fi;
unset doIt;