-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall
31 lines (22 loc) · 805 Bytes
/
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
#!/bin/bash
DOTFILES="$HOME/.dotfiles"
hash git 2>&- || { echo >&2 "Git is required but missing."; exit 1; }
if [[ ! -d $DOTFILES ]]; then
git clone -q git://github.com/davgothic/dotfiles.git $DOTFILES
[[ ! -d $DOTFILES ]] && { echo >&2 "Could not clone the dotfiles repository."; exit 1; }
fi
cd $DOTFILES && git pull -q && git submodule update -q --init --recursive
FILES=$(find $DOTFILES -mindepth 1 -maxdepth 1 | grep -Ev '(\.git|install|README)')
for FILE in $FILES; do
FILENAME=".$(basename $FILE)"
if [[ -f "$HOME/$FILENAME" && ! -f "$HOME/$FILENAME.bak" ]]; then
mv "$HOME/$FILENAME" "$HOME/$FILENAME.bak"
fi
if [[ -f "$HOME/$FILENAME" || -d "$HOME/$FILENAME" ]]; then
rm -r "$HOME/$FILENAME"
fi
ln -s $FILE "$HOME/$FILENAME"
done
unset DOTFILES
unset FILES
. "$HOME/.bashrc"