To replace all calls to git
with git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME
, you can use a function:
git() {
command git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME "$@"
}
However, you don’t actually have to do that for this case. Instead of passing those option flags to git
, you can just specify them through environment variables instead:
export GIT_DIR=$HOME/.dotfiles/
export GIT_WORK_TREE=$HOME
See https://www.git-scm.com/docs/git#Documentation/git.txt---git-dirltpathgt
As an aside, instead of maintaining and trying to remember a large amount of aliases, you could instead just use zsh-autocomplete
’s history completion mode. (Disclaimer: I’m the maintainer of this plugin.)