ohmyzsh: git completion fails when complete_aliases option is set
I’m running zsh 5.0.4 on OS X 10.8 with oh-my-zsh a38af27 with the git plugin. When I type gco <TAB>, I get the following output:
% gco zsh:12: command not found: __git-checkout_main
extegco
file
MIT-LICENSE.txt custom/ log/ plugins/ themes/
README.textile lib/ oh-my-zsh.sh templates/ tools/
I’ve found the culprit to be the option complete_aliases. Once I turn it off, everything works as expected.
What gives? Is there any option clash? I haven’t changed my .zshrc in ages, and I’ve always had complete_aliases on.
I don’t particularly need this option but I guess there’s some bug here.
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 40 (20 by maintainers)
Commits related to this issue
- zsh: remove complete_alias option as it breaks git completion See https://github.com/robbyrussell/oh-my-zsh/issues/2394 — committed to cbliard/dotfiles by deleted user 9 years ago
- Unset complete_aliases See discussion: * https://github.com/robbyrussell/oh-my-zsh/issues/2394 * http://zsh.sourceforge.net/Guide/zshguide06.html — committed to derekprior/dotfiles by derekprior 9 years ago
- This _almost_works https://github.com/robbyrussell/oh-my-zsh/issues/2394#issuecomment-45287624 Unfortunately, it doesn't complete remote branches. — committed to gabebw/dotfiles by gabebw 7 years ago
The problem here is that the official Git completion was not prepared for ‘complete_aliases’, I’ve pushed a fix:
https://github.com/felipec/git/commit/aaafa76
This way you can manually define the completion with:
However, if you want to use zsh’s format:
gco=git-checkoutand for it to work in the currently distributed version of Git, you can do this:@mcornella Sorry for the late reply. I did not have access to the machine that exposed the problem.
Running
solved the problem indeed.
Thank you very much for your investigation.
@mecampbellsoup yes, that could be helpful! I recommend the use of
git-bisect.The non-reproducibility of the issue suggests that it has something to do with your config, and the fact that it still happens with the template
.zshrcindicates that it is not related to your OMZ config.Let us start with determining what the
compdefstatement should do. Reading through Zsh completion manual indicates a bit more about how it should work:But then I had a look at the Zsh git completion (with the oh-so-evil 6661 line count), and
git-checkoutis not listed in the#compdefstatement, and$serviceis not checked for it either. So I have no clue as to whycompdef _git gco=git-checkoutworks — but it does work!@pielgrzym can you enlighten us about 2e9492969b0ea90932ad3f4298330b75ef8cf2ce?