3

I have a few aliases that I want to autocomplete for git, e.g., the following

alias gco="git checkout"

When I was attempting to add completions for this alias, I looked around in my path and saw that a bunch of git completions were available (e.g., _git-push, _git-checkout, _git-diff-files). AndI used compdef to define it:

compdef _git-checkout gco

This worked for a while, then I restarted my terminal and suddenly they were all gone... (getting an error about completions not available):

gco (eval):1: command not found: _git-checkout
(eval):1: command not found: _git-checkout
(eval):1: command not found: _git-checkout

The weird part is that they all get dumped into my path after I run git reflog. (and then they work). Am I relying on some internal functions here that I shouldn't be? Should I go about this differently? (I could also just add a git reflog into my .zshrc, but that seems totally ridiculous to do).

  • 1
    ZSH (at least 5.0.2 on my machine) is able to do proper autocompletion on that alias without doing anything after setting up the alias. It would be nice to know which version of ZSH you're using if that's not working out of the box for you. – Wieland Aug 18 '13 at 15:24
  • @Wieland version: zsh 5.0.0 (x86_64-apple-darwin12.0.0) – Jeff Tratner Sep 17 '13 at 5:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.