Last active
March 3, 2019 16:53
-
-
Save fgandellini/a1b0ef1d75e760b4f6d902ca74c39213 to your computer and use it in GitHub Desktop.
Script needed to restore dotfiles from https://github.com/fgandellini/dotfiles
This file contains 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/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