Skip to content

Instantly share code, notes, and snippets.

@tresni
Last active September 1, 2021 03:14
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 tresni/3468f2dea2becb2104f96aaa508816c2 to your computer and use it in GitHub Desktop.
Save tresni/3468f2dea2becb2104f96aaa508816c2 to your computer and use it in GitHub Desktop.
#! /bin/bash
GIT_REPO=${GIT_REPO:-git@github.com:tresni/dotfiles.git}
DOTFILES_PATH=${DOTFILES_PATH:-$HOME/.dotfiles}
git clone --bare "${GIT_REPO}" "${DOTFILES_PATH}"
function dotfiles {
/usr/bin/git --git-dir="${DOTFILES_PATH}" --work-tree="$HOME" $@
}
mkdir -p "${DOTFILES_PATH}-backup"
dotfiles checkout
if [ $? = 0 ]; then
echo "Checked out dotfiles.";
else
echo "Backing up pre-existing dot files.";
for fn in $(dotfiles checkout 2>&1 | egrep "\s+\." | awk {'print $1'}); do
mkdir -p "${DOTFILES_PATH}-backup/$(dirname $fn)";
mv "$fn" "${DOTFILES_PATH}-backup/$fn"
done
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