Skip to content

Instantly share code, notes, and snippets.

@NickCrew
Created July 30, 2021 15:22
Show Gist options
  • Save NickCrew/1f2097bab027e0747483649a4d6c5f70 to your computer and use it in GitHub Desktop.
Save NickCrew/1f2097bab027e0747483649a4d6c5f70 to your computer and use it in GitHub Desktop.
Install dots
#!/usr/bin/env bash
set -e
function cfg {
git --work-tree=$HOME --git-dir=$HOME/.cfg $@
}
git clone --bare https://github.com/NickCrew/dotfiles.git $HOME/.cfg
mkdir -p .config-backup
cfg checkout
if [ $? = 0 ]; then
echo "Checked out config. Branch: ${branch}";
else
echo "Backing up pre-existing dot files.";
cfg checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
fi;
cfg checkout
cfg config status.showUntrackedFiles no
if [ -f ~/.config/cfg/bootstrap ]; then
ln -s ~/.config/cfg/bootstrap ~/bin/bootstrap-cfg
fi
echo "'cfg' command is now available. Accepts all standard git arguments."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment