4

I encounter a problem with Zsh autocompletion for some specific git commands (the ones involving a remote and a branch), but only when using aliases.

Here is an example with push:

$ git push o<TAB>rigin m<TAB>aster  # tab completion works
$ git config --global alias.ps push # set a `ps` alias for `push`
$ git ps o<TAB>rigin m<TAB>         # tab completion doesn't work for "master"

The same problem occurs with pull and fetch.

My .zshrc can be found here, but I don't think it is related, as I was able to reproduce the problem without using it (just enabling the autocompletion with autoload -U compinit && compinit).

I'm running OSX 10.9 with the following software versions (both of them installed through brew):

$ zsh --version
zsh 5.0.2 (x86_64-apple-darwin13.0.0)
$ git --version
git version 1.8.4.2

This problem appeared since I did an OSX 10.9 clean install. So I presume it comes from a recent update either from Zsh or Git.

aymericbeaumet
  • 6,853
  • 2
  • 37
  • 50

2 Answers2

2

Maybe you should use Git's official completion for zsh:

https://git.kernel.org/cgit/git/git.git/tree/contrib/completion/git-completion.zsh

FelipeC
  • 9,123
  • 4
  • 44
  • 38
2

The problem came from a bug in the Git completion for both Bash and Zsh. @felipec took the time to fix it. Thanks, it works like a charm now!

Community
  • 1
  • 1
aymericbeaumet
  • 6,853
  • 2
  • 37
  • 50
  • Hm, I still have this issue - was this fixed using git's git-completion.zsh instead of Zsh? Or is it fixed in an update to Zsh? – Achal Dave Jan 14 '14 at 04:09
  • 1
    I installed @felipec completion files: https://github.com/felipec/git/blob/fc/master/contrib/completion/git-completion.bash and https://github.com/felipec/git/blob/fc/master/contrib/completion/git-completion.zsh, it works well. – aymericbeaumet Jan 14 '14 at 07:58
  • Ah awesome, thanks! I'm using git's completion files, which I assume are closer to felipec's than zsh's completion is, and the one thing I miss is Zsh's autocompletion gave descriptions of aliases. So for example, if I had lg='log --graph' as an alias, git l would show lg, along with what it was aliased to. Ah well, this is probably worth more. – Achal Dave Jan 14 '14 at 18:19
  • still has this problem. and above link is dead – chinaanihchen Dec 14 '18 at 10:31
  • 1
    It's been merged upstream since, so you can try these links: https://github.com/git/git/blob/master/contrib/completion/git-completion.bash and https://github.com/git/git/blob/master/contrib/completion/git-completion.zsh. Also, I guess you shouldn't face this issue with an updated install? What os/git versions are you using? – aymericbeaumet Dec 15 '18 at 08:11