Skip to content

Instantly share code, notes, and snippets.

@lytvynda
Last active February 6, 2025 15:58
Show Gist options
  • Save lytvynda/e246473074180e7ea1fb6e37e71fe3b2 to your computer and use it in GitHub Desktop.
Save lytvynda/e246473074180e7ea1fb6e37e71fe3b2 to your computer and use it in GitHub Desktop.
Clone bare repository with dotfiles and setup dotfiles
set -e
git clone --bare https://github.com/lytvynda/dotfiles.git $HOME/.cfg
function dotfiles {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
dotfiles checkout > /dev/null 2>&1
if [ $? = 0 ]; then
echo "Checked out dotfiles";
else
echo "Backing up pre-existing dot files into .config-backup";
mkdir -p .config-backup
dotfiles checkout 2>&1 | egrep "\s+\." | awk '{print $1}' | xargs -I{} sh -c 'mv "{}" ".config-backup/$(basename "{}")"'
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