Last active
May 23, 2019 14:12
-
-
Save lidopaglia/a7342485140f40d6216181323d26df0b to your computer and use it in GitHub Desktop.
Backup existing homedir files and install dotfiles as bare git repo
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
#!/bin/bash | |
git clone --bare https://github.com/lidopaglia/dotfiles.git $HOME/.dotfiles | |
function dot { | |
/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@ | |
} | |
mkdir -p .dotfiles-backup | |
dot checkout | |
if [ $? = 0 ]; then | |
echo "Checked out dotfiles."; | |
else | |
echo "Backing up pre-existing dotfiles."; | |
dot checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .dotfiles-backup/{} | |
fi; | |
dot checkout | |
dot config status.showUntrackedFiles no |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment