Last active
April 20, 2018 11:49
-
-
Save mfaerevaag/6f81eb5aab8412dc1e5d1698d6abfb04 to your computer and use it in GitHub Desktop.
Import dot files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/sh | |
REPO="https://github.com/mfaerevaag/dots.git" | |
DIR="$HOME/.dots" | |
BACKUP="$HOME/.dots-backup" | |
function dots { | |
/usr/bin/git --git-dir=$DIR --work-tree=$HOME $@ | |
} | |
# clone | |
git clone -b bare --single-branch --bare $REPO $DIR | |
# import | |
dots checkout | |
# check if existing | |
if [ $? -eq 0 ]; then | |
echo "Checked out dots" | |
else | |
echo "Backing up pre-existing dot files..." | |
mkdir -p $BACKUP | |
dots checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} $BACKUP/{} | |
if dots checkout; then | |
echo "Checked out dots" | |
else | |
echo "Something failed" | |
fi | |
fi | |
# ignore untracked files | |
dots config status.showUntrackedFiles no | |
# clean up | |
unset REPO | |
unset DIR | |
unset BACKUP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install with