Skip to content

Instantly share code, notes, and snippets.

@lukehsiao
Last active April 30, 2017 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lukehsiao/b972e21ad914fc31f6a9d6afa8e32c5f to your computer and use it in GitHub Desktop.
Save lukehsiao/b972e21ad914fc31f6a9d6afa8e32c5f to your computer and use it in GitHub Desktop.
dotfile-cfg
git init --bare $HOME/.cfg
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
config config --local status.showUntrackedFiles no
echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.bashrc
git clone --bare https://lukehsiao@github.com/lukehsiao/dotfiles.git $HOME/.cfg
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
mkdir -p .config-backup
config checkout
if [ $? = 0 ]; then
echo "[info] Checked out config.";
else
echo "[info] Backing up pre-existing dot files.";
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
fi;
config checkout
config config status.showUntrackedFiles no
echo "[info] Completed download of dotfiles."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment