This repository has been archived by the owner on Feb 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
bootstrap.sh
executable file
·67 lines (56 loc) · 1.57 KB
/
bootstrap.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
#!/bin/bash
#
# bootstrap.sh
# Symlink all dotfiles in this repo to their appropriate location.
#
# Inspired by https://github.com/bamos/dotfiles/blob/master/bootstrap.sh
set -e
if [[ -z "$XDG_CONFIG_HOME" ]]; then
XDG_CONFIG_HOME="$HOME/.config"
fi
link_file() {
local ORIG="$1"; local NEW="$2"
echo " '$ORIG'"
if [[ $BACKUP =~ ^[Yy]$ ]] && [ ! -h $ORIG ]; then
mv "$ORIG" "${ORIG}.save" &> /dev/null \
&& echo " ...backed up"
else
rm -rf "$ORIG"
echo " ...deleted"
fi
ln -s "$NEW" "$ORIG" && echo " ...linked"
}
if [[ $# == 1 ]]; then
[[ $1 =~ '-y' ]] && BACKUP='y'
[[ $1 =~ '-n' ]] && BACKUP='n'
else
read -p "Backup files ? [Y/n] " -n 1; echo
BACKUP=$REPLY
if [[ $BACKUP == '' ]]; then
BACKUP='y'
fi
fi
cd "$(dirname "${BASH_SOURCE}")" # Switch to dotfiles directory
echo "Symlinking..."
for DOTFILE in $(find -L . -maxdepth 1 -type f ! -name '.*'); do
[[ $DOTFILE != './bootstrap.sh' ]] \
&& [[ $DOTFILE != './README.md' ]] \
&& [[ $DOTFILE != './LICENSE' ]] \
&& [[ ! $DOTFILE =~ pkglist ]] \
&& link_file "$HOME/.$(basename $DOTFILE)" "$PWD/$DOTFILE"
done
mkdir -p $HOME/.config
for DOTFILE in $(find -L . -maxdepth 1 -type d ! -path . ! -path './.*'); do
if [[ $DOTFILE = './vim' ]]; then
link_file "$HOME/.$(basename $DOTFILE)" "$PWD/$DOTFILE"
else
[[ $DOTFILE != './screenshots' ]] \
&& link_file "$XDG_CONFIG_HOME/$(basename $DOTFILE)" "$PWD/$(basename $DOTFILE)"
fi
done
# Install vim-plug plugins
if [[ -x "$(which nvim)" ]]; then
nvim +PlugInstall +qall
else
vim +PlugInstall +qall
fi