zsh-users
 help / color / mirror / code / Atom feed
* How to set up completion for git aliases?
@ 2012-07-06 17:04 Vadim Zeitlin
  2012-07-06 17:56 ` Axel Beckert
  2012-07-06 23:02 ` Frank Terbeck
  0 siblings, 2 replies; 8+ messages in thread
From: Vadim Zeitlin @ 2012-07-06 17:04 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 451 bytes --]

 Hello,

 I have a simple git alias "lg = log --oneline" and I'd like zsh to
complete it in the same way as it already completes "git log".
Unfortunately after spending a long time looking at
/usr/share/zsh/functions/Completion/Unix/_git I still have no idea how am I
supposed to do it "properly", i.e. without copying this huge file and
hacking on it. I'm sure there must be a better way to do it but which one?

 Thanks in advance for any hints,
VZ

[-- Attachment #2: Type: APPLICATION/PGP-SIGNATURE, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set up completion for git aliases?
  2012-07-06 17:04 How to set up completion for git aliases? Vadim Zeitlin
@ 2012-07-06 17:56 ` Axel Beckert
  2012-07-06 23:02 ` Frank Terbeck
  1 sibling, 0 replies; 8+ messages in thread
From: Axel Beckert @ 2012-07-06 17:56 UTC (permalink / raw)
  To: zsh-users

Hi,

On Fri, Jul 06, 2012 at 07:04:53PM +0200, Vadim Zeitlin wrote:
>  I have a simple git alias "lg = log --oneline" and I'd like zsh to
> complete it in the same way as it already completes "git log".
> Unfortunately after spending a long time looking at
> /usr/share/zsh/functions/Completion/Unix/_git I still have no idea how am I
> supposed to do it "properly", i.e. without copying this huge file and
> hacking on it. I'm sure there must be a better way to do it but which one?

I'm not sure if there's much necessary with stock zsh, but I use
grml's zshrc (http://grml.org/zsh/) and it works out of the box with
every freshly added alias for me. Never had to do anything.

HTH.

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
 X   See http://www.asciiribbon.org/              | abe@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://noone.org/abe/ (Web)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set up completion for git aliases?
  2012-07-06 17:04 How to set up completion for git aliases? Vadim Zeitlin
  2012-07-06 17:56 ` Axel Beckert
@ 2012-07-06 23:02 ` Frank Terbeck
  2012-07-07  0:52   ` Re[2]: " Vadim Zeitlin
  2012-11-01  0:01   ` Re[2]: " Vadim Zeitlin
  1 sibling, 2 replies; 8+ messages in thread
From: Frank Terbeck @ 2012-07-06 23:02 UTC (permalink / raw)
  To: Zsh Users

Vadim Zeitlin wrote:
>  I have a simple git alias "lg = log --oneline" and I'd like zsh to
> complete it in the same way as it already completes "git log".
> Unfortunately after spending a long time looking at
> /usr/share/zsh/functions/Completion/Unix/_git I still have no idea how am I
> supposed to do it "properly", i.e. without copying this huge file and
> hacking on it. I'm sure there must be a better way to do it but which one?

You don't need to do anything, unless you're on a quite old version of
zsh. The _git completion has support for that out of the box.

I don't remember when the feature was added exactly, but any release
within the last year should be new enough.

Gruß Frank


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re[2]: How to set up completion for git aliases?
  2012-07-06 23:02 ` Frank Terbeck
@ 2012-07-07  0:52   ` Vadim Zeitlin
  2012-07-17 19:20     ` Axel Beckert
  2012-11-01  0:01   ` Re[2]: " Vadim Zeitlin
  1 sibling, 1 reply; 8+ messages in thread
From: Vadim Zeitlin @ 2012-07-07  0:52 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 704 bytes --]

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

FT> You don't need to do anything, unless you're on a quite old version of
FT> zsh.

 Sorry, I should have mentioned that I use (quite old) 4.3.10 (from Debian
Squeeze).

FT> I don't remember when the feature was added exactly, but any release
FT> within the last year should be new enough.

 I tried grabbing just the latest _git but it fails with

_arguments:comparguments:312: invalid argument: (-v          --header)

error so it looks like I'd have to install a new zsh version locally.

 Anyhow, thank you and Axel for your answers, at least I won't waste time
trying to understand how to do it myself.

 Thanks,
VZ

[-- Attachment #2: Type: APPLICATION/PGP-SIGNATURE, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set up completion for git aliases?
  2012-07-07  0:52   ` Re[2]: " Vadim Zeitlin
@ 2012-07-17 19:20     ` Axel Beckert
  2012-07-17 19:54       ` Frank Terbeck
  0 siblings, 1 reply; 8+ messages in thread
From: Axel Beckert @ 2012-07-17 19:20 UTC (permalink / raw)
  To: zsh-users

Hi again,

On Sat, Jul 07, 2012 at 02:51:50AM +0200, Vadim Zeitlin wrote:
> FT> You don't need to do anything, unless you're on a quite old version of
> FT> zsh.
> 
>  Sorry, I should have mentioned that I use (quite old) 4.3.10 (from Debian
> Squeeze).
> 
> FT> I don't remember when the feature was added exactly, but any release
> FT> within the last year should be new enough.
> 
>  I tried grabbing just the latest _git but it fails with
> 
> _arguments:comparguments:312: invalid argument: (-v          --header)
> 
> error so it looks like I'd have to install a new zsh version locally.

Hrm, in my case git tab completion works fine with aliases on Debian
Squeeze, too. E.g. with dc="diff --cached", git dc --<Tab> works as
expected as well as "git dc -- <Tab>" does.

Not sure how much of it comes from grml's zshrc (ft may be able to
tell :-), but it's definitely doable with zsh 4.3.10 from Squeeze. :-)

		Kind regards, Axel
-- 
/~\  Plain Text Ribbon Campaign                   | Axel Beckert
\ /  Say No to HTML in E-Mail and News            | abe@deuxchevaux.org  (Mail)
 X   See http://www.asciiribbon.org/              | abe@noone.org (Mail+Jabber)
/ \  I love long mails: http://email.is-not-s.ms/ | http://noone.org/abe/ (Web)


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: How to set up completion for git aliases?
  2012-07-17 19:20     ` Axel Beckert
@ 2012-07-17 19:54       ` Frank Terbeck
  0 siblings, 0 replies; 8+ messages in thread
From: Frank Terbeck @ 2012-07-17 19:54 UTC (permalink / raw)
  To: zsh-users

Axel Beckert wrote:
[...]
> Hrm, in my case git tab completion works fine with aliases on Debian
> Squeeze, too. E.g. with dc="diff --cached", git dc --<Tab> works as
> expected as well as "git dc -- <Tab>" does.
>
> Not sure how much of it comes from grml's zshrc (ft may be able to
> tell :-), but it's definitely doable with zsh 4.3.10 from Squeeze. :-)

grml's setup does nothing in particular to support this.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re[2]: How to set up completion for git aliases?
  2012-07-06 23:02 ` Frank Terbeck
  2012-07-07  0:52   ` Re[2]: " Vadim Zeitlin
@ 2012-11-01  0:01   ` Vadim Zeitlin
  2012-11-01  4:46     ` Benjamin R. Haskell
  1 sibling, 1 reply; 8+ messages in thread
From: Vadim Zeitlin @ 2012-11-01  0:01 UTC (permalink / raw)
  To: Zsh Users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1548 bytes --]

On Sat, 07 Jul 2012 01:02:43 +0200 Frank Terbeck <ft@bewatermyfriend.org> 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.

 Thanks in advance,
VZ

[-- Attachment #2: Type: APPLICATION/PGP-SIGNATURE, Size: 196 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re[2]: How to set up completion for git aliases?
  2012-11-01  0:01   ` Re[2]: " Vadim Zeitlin
@ 2012-11-01  4:46     ` Benjamin R. Haskell
  0 siblings, 0 replies; 8+ messages in thread
From: Benjamin R. Haskell @ 2012-11-01  4:46 UTC (permalink / raw)
  To: Vadim Zeitlin; +Cc: Zsh Users

On Thu, 1 Nov 2012, Vadim Zeitlin wrote:

> On Sat, 07 Jul 2012 01:02:43 +0200 Frank Terbeck <ft@bewatermyfriend.org> 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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-11-01  4:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-06 17:04 How to set up completion for git aliases? Vadim Zeitlin
2012-07-06 17:56 ` Axel Beckert
2012-07-06 23:02 ` Frank Terbeck
2012-07-07  0:52   ` Re[2]: " Vadim Zeitlin
2012-07-17 19:20     ` Axel Beckert
2012-07-17 19:54       ` Frank Terbeck
2012-11-01  0:01   ` Re[2]: " Vadim Zeitlin
2012-11-01  4:46     ` Benjamin R. Haskell

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).