Skip to content

Instantly share code, notes, and snippets.

@fgandellini
Last active March 3, 2019 16:53
Show Gist options
  • Save fgandellini/a1b0ef1d75e760b4f6d902ca74c39213 to your computer and use it in GitHub Desktop.
Save fgandellini/a1b0ef1d75e760b4f6d902ca74c39213 to your computer and use it in GitHub Desktop.
Script needed to restore dotfiles from https://github.com/fgandellini/dotfiles
#!/bin/sh
git clone --bare https://github.com/fgandellini/dotfiles $HOME/.dotfiles
function dotfiles {
/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME $@
}
mkdir -p .dotfiles-backup
dotfiles checkout
if [ $? = 0 ]; then
echo "Checked out dotfiles.";
else
echo "Backing up pre-existing dotfiles.";
dotfiles checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} bash -c 'mkdir -p .dotfiles-backup/$(dirname {}); mv {} .dotfiles-backup/{}'
fi;
dotfiles checkout
dotfiles config status.showUntrackedFiles no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment