From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10188 invoked by alias); 1 Nov 2012 04:47:03 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17370 Received: (qmail 20164 invoked from network); 1 Nov 2012 04:46:59 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) Date: Thu, 1 Nov 2012 00:46:24 -0400 (EDT) From: "Benjamin R. Haskell" To: Vadim Zeitlin cc: Zsh Users Subject: Re[2]: How to set up completion for git aliases? In-Reply-To: Message-ID: References: <87liiwtrvw.fsf@ft.bewatermyfriend.org> User-Agent: Alpine 2.01 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed On Thu, 1 Nov 2012, Vadim Zeitlin wrote: > On Sat, 07 Jul 2012 01:02:43 +0200 Frank Terbeck 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