I have a custom Zsh function g
:
function g() {
# Handle arguments [...]
}
Within it, I handle short arguments that execute Git commands. For example:
g ls # Executes git ls-files ...
g g # Executes git grep ...
I need to be able to set the autocompletion rules to Git's rules for the short arguments but I am unsure of how to do this.
For example, I need g ls <TAB>
to tab-complete the rules for git ls-files <TAB>
which would give me the arguments for git ls-files
:
$ g ls --<TAB>
--abbrev -- set minimum SHA1 display-length
--cached -- show cached files in output
--deleted -- show deleted files in output
# Etc...
This is not simply setting g
to autocomplete for git
since I'm mapping my custom short commands to the Git commands.
man git-config
.