0

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.

hibbelig
  • 510
  • 6
  • 15
  • Try doing a `zsh -lx` to see where that `__mgit_main` call is happening. And add the details here - might help further debug. – nitishagar Jul 09 '19 at 08:06
  • @nitishagar I'm sorry I don't know how to use `zsh -lx`. I started a new shell with `zsh -lx` which emitted a lot of messages before displaying the prompt. I presume those messages are not important. But when I typed `mgit st` and then hit Tab, nothing else was printed besides the error message that was already part of my question. – hibbelig Jul 09 '19 at 11:28
  • Can you run `zsh -lx` as a command in the shell where you just ran the `mgit st` command. This should give a trace of what happened with autocomplete err. – nitishagar Jul 09 '19 at 13:56
  • 1
    I have `/usr/local/share/zsh/functions/_git` which seems to be part of zsh, but I _also_ have `/usr/local/share/zsh/site-functions/_git` and `/usr/local/share/zsh/site-functions/git-completion.bash` which installed as part of git. I suspect that these are stepping on each other's toes. Also I'm a bit unclear which one is being used. I suspect that clearing this up will help with my problem. – hibbelig Jul 09 '19 at 15:01

0 Answers0