Last active
September 1, 2021 03:14
-
-
Save tresni/3468f2dea2becb2104f96aaa508816c2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
GIT_REPO=${GIT_REPO:[email protected]: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