Skip to content

Instantly share code, notes, and snippets.

@snowfag
Last active January 1, 2021 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save snowfag/7eac28fc0628dcc86fc71b12e25a8c40 to your computer and use it in GitHub Desktop.
Save snowfag/7eac28fc0628dcc86fc71b12e25a8c40 to your computer and use it in GitHub Desktop.
#!/usr/bin/env zsh
if [[ -d ${HOME}/.cfg ]]; then
if read -q "choice?${HOME}/.cfg exists would you like to delete it? Y/n: "; then
rm -rf "${HOME}/.cfg"
else
exit 1
fi
fi
git clone --bare git@github.com:snowfag/dotfiles.git ${HOME}/.cfg
config() git --git-dir=${HOME}/.cfg/ --work-tree=${HOME} $@
if config checkout 2>&1 >/dev/null; then
echo "Checked out config."
else
echo "Backing up pre-existing dot files."
OLDFILES=$(mktemp -d)
config checkout 2>&1 | egrep "\s+\." | cut -f 2 | xargs -I{} mv "{}" "${OLDFILES}/{}"
config checkout
config config status.showUntrackedFiles no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment