Skip to content

Instantly share code, notes, and snippets.

@hectorm
Created February 4, 2018 10:48
Show Gist options
  • Save hectorm/8891f7f1916a4379f84dfaccc6fa117f to your computer and use it in GitHub Desktop.
Save hectorm/8891f7f1916a4379f84dfaccc6fa117f to your computer and use it in GitHub Desktop.
#!/bin/sh
set -eu
GIT_DIR="${HOME}/.dotfiles";
GIT_CMD="${1:-}"
dotgit() {
git --git-dir="${GIT_DIR}" --work-tree="${HOME}" "$@"
}
if [ "${GIT_CMD}" = 'dotinit' ]; then
git init --bare "${GIT_DIR}";
dotgit config --local status.showUntrackedFiles no
elif [ "${GIT_CMD}" = 'dotclone' ]; then
GIT_REPO="$2"
git clone --bare --recursive "${GIT_REPO}" "${GIT_DIR}"
dotgit config --local status.showUntrackedFiles no
dotgit checkout --force
elif [ "${GIT_CMD}" = 'dotsave' ]; then
GIT_MESSAGE="${2:-$(date +%s)}"
dotgit commit --all -m "${GIT_MESSAGE}"
dotgit push origin master
else
dotgit "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment