Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: _git Completion and custom commands

On 28 September 2010 09:03, Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:
> Benjamin R. Haskell <zsh@xxxxxxxxxx>:
> [...]
>>> The one issue I've found is that the _git completion function (as of
>>> 4.3.10 shipped with Debian testing) does not include custom commands
>>> (though it does include aliases).
> [...]
>> zstyle ':completion:*:git:*' user-commands ${${(k)commands[(I)git-*]}#git-}

This is perfect — thank you!

> Yes, this is explained at the top of the _git completion file.

On some version later than the version I used to have. Thank you for
your help (on IRC) in getting the right version of the _git function,
which allowed Ben's command to work.

> Now, if you want smartness, when you try `git foo <tab>' you may
> write a function `_git-foo()' and _git will pick it up. So, if
> your `git-foo' program supports a few options (-f, -v and -q), a
> completion function may look like this:
> The `style' line Benjamin gave sets the `user-commands' style to a
> list of all `git-*' commands zsh finds in $PATH. It's useful if you
> got a *lot* of own scripts. Since zsh cannot guess a description for
> the programs this way, commands added like that will be missing
> descriptions.

I do have a large number of commands, but luckily I know what they do
:). So I'm going with the automagic rather than the explicit — though
I may consider the additional options for the few commands that take
several options (particularly those that mix the arguments of other
git commands)

> PS: If the OP didn't configure compsys yet, then
>    <http://zshwiki.org/home/examples/compquickstart> may serve him
>    as a quickstart. I'll certainly help to get menus such as the
>    ones I mentioned above.
I was just comparing this to the default that Debian gave me — I'll
have to investigate further.

Thanks to everyone.


Messages sorted by: Reverse Date, Date, Thread, Author