I was experimenting with custom git subcommand completion:
I am trying to extend the completion for git commit -m
or git commit --message
.
$HOME/.zsh/completions/_git-foo (this path is added to fpath fpath+=~/.zsh/completions)
#compdef git-foo
_git-foo() {
_git-commit
local -a commands
commands=(
'hello-git:our first autocompletion function.'
'version:show the used gem version.'
)
if (( CURRENT == 3 )); then
if [[ $words[2] == "--message" || $words[2] == "--message=" || $words[2] == "-m" ]]; then
_describe -t commands 'commands' commands
fi
fi
return 0
}
_git-foo
but the main objective is to add this additional completion to the already defined _git-commit
completion without breaking the original completion function for git commit
I have tried to change the #compdef
directive to #compdef git-commit
and file name from _git-foo
to _git-commit
but it didn't work.
I was getting the following error:
_git-commit:1: maximum nested function level reached; increase FUNCNEST?
_git-commit:1: maximum nested function level reached; increase FUNCNEST?
_git-commit:1: maximum nested function level reached; increase FUNCNEST?
Creating your custom completion for a custom subcommand works fine, but how to extend the already defined git completions without breaking the original one?