Skip to content

Instantly share code, notes, and snippets.

@lidopaglia
Last active May 23, 2019 14:12
Show Gist options
  • Save lidopaglia/a7342485140f40d6216181323d26df0b to your computer and use it in GitHub Desktop.
Save lidopaglia/a7342485140f40d6216181323d26df0b to your computer and use it in GitHub Desktop.
Backup existing homedir files and install dotfiles as bare git repo
#!/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