Skip to content

Instantly share code, notes, and snippets.

@landersson
Last active January 26, 2021 12:27
Show Gist options
  • Save landersson/2ad0a7352d597e5ef3032b3bf1eaea22 to your computer and use it in GitHub Desktop.
Save landersson/2ad0a7352d597e5ef3032b3bf1eaea22 to your computer and use it in GitHub Desktop.
# curl -# -L https://gist.githubusercontent.com/landersson/2ad0a7352d597e5ef3032b3bf1eaea22/raw | bash
function config {
/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME $@
}
REPO_METHOD=${1:-"git"}
if [[ $REPO_METHOD == "git" ]]; then
REPO_URL="git@github.com:landersson/cfg.git"
elif [[ $REPO_METHOD == "http" ]]; then
REPO_URL="https://github.com/landersson/cfg.git"
else
echo "Unsupported repo access method '$REPO_METHOD'"
exit 1
fi
if [ -d $HOME/.cfg ]; then
echo "Directory $HOME/.cfg already exists... attempting update"
if ! config pull; then
echo "Failed to update git repo. Aborting."
exit 1
fi
else
git clone --bare $REPO_URL $HOME/.cfg
fi
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{} mv {} .config-backup/{}
fi;
config checkout
config config status.showUntrackedFiles no
$HOME/.scripts/install/install-config.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment