I have written a little shell script called mgit
that executes the same git command in multiple repositories. I would like to tell zsh that arguments to mgit
should be completed like git
arguments.
For example, I can type git st
and hit tab, and this will complete to git status
. So I would like to type mgit st
and hit tab, and have this complete to mgit status
.
So in my own very blond way, I typed compdef _git mgit
, and then I typed mgit st
followed by tab, and this is what I got:
foo% mgit st_git:12: command not found: __mgit_main
mgit
So I searched /usr/local/share/zsh/functions/_git
for the word main
but it was not elucidating.
I would like to clarify that mgit status
already does what I want, this question is only about completion.
I would like to further clarify that I know that my approach will lead to "wrong" completions sometimes, e.g. mgit checkout feature/<TAB>
will complete branch names from the current repository, instead of doing something complicated such as computing the intersection of all branch names across the multiple repos. I'm fine with this.
Running zsh 5.7.1 on macOS, installed via Homebrew.