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

Re[2]: How to set up completion for git aliases?



On Thu, 1 Nov 2012, Vadim Zeitlin wrote:

On Sat, 07 Jul 2012 01:02:43 +0200 Frank Terbeck <ft@xxxxxxxxxxxxxxxxxxx> wrote:

FT> Vadim Zeitlin wrote:
FT> > I have a simple git alias "lg = log --oneline" and I'd like zsh to FT> > complete it in the same way as it already completes "git log".
...
FT> You don't need to do anything, unless you're on a quite old version of FT> zsh. The _git completion has support for that out of the box.

Hello,

I'd like to return to this thread because I think that this (very useful) feature doesn't play well with the method of setting up custom completion for git subcommands described in the standard Completion/Unix/_git: the comment in the beginning of this file says that you should be able to simply defined your own _git-foo completion function to handle completion of "git foo". Unfortunately this doesn't seem to work or, actually, it does work as long as "foo" is really an external command and not an alias. But if I have "foo" defined as an alias in my ~/.gitconfig, then it seems that the alias completion takes over and it tries to complete the "!sh -c ..." alias expansion which, unsurprisingly, doesn't work really well.

Is there some way to tell git completion to use _git-foo if it's defined even if foo is an alias? I tried to find it but unfortunately _git file is just too much for me...

Of course, there is always the solution of actually using an external command instead of an alias but having an alias is often more convenient for simple one-liners so it would be nice if it could be made to work.

I recently posted a patch to make this work:

zsh-workers 30737
http://www.zsh.org/mla/workers/2012/msg00643.html

For the example mentioned (git alias "lg = log --oneline"), if the function _git-lg exists, the patch will let it be used for completion.

--
Best,
Ben



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