Skip to content

Instantly share code, notes, and snippets.

@vuthanglong
Last active April 21, 2023 05:32
Show Gist options
  • Save vuthanglong/cbe87b70e3df5a32e24354b6bd33eb64 to your computer and use it in GitHub Desktop.
Save vuthanglong/cbe87b70e3df5a32e24354b6bd33eb64 to your computer and use it in GitHub Desktop.
Automatically set up configuration files from my repo
git clone --bare https://github.com/vuthanglong/.config $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "Checked out config.";
else
echo "Backing up pre-existing dot files.";
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I % sh -c 'mkdir --parents .config-backup/%;mv % .config-backup/%'
fi;
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