Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When you define an alias like alias g=git, the shell will pick it up and run the corresponding autocomplete function. Now, there's a program out there called hub, which is basically a supserset of git, with some added, github-specific functionality. The recommended way to use hub is to alias git=hub. Of course, this won't trigger the autocomplete function for git, which makes sense.

Now, if I wanted to have git's autocomplete trigger for hub, the only way I know of is editing /usr/share/zsh/functions/Completion/Unix/_git and adding hub in the first line as trigger. While this works, it isn't practical, since this file will get overwritten with the next zsh release. Assuming hub won't provide a zsh completion function any time soon, is there another way of adding hub to the trigger commands for git's autocomplete function?

share|improve this question
Turns out this was a duplicate for a question on SO:… – mkaito Jun 3 '12 at 15:15

You can define an additional autocomplete folder which can have your custom definitions in it. If you have something similar to the default .zshrc then you just need to update the $fpath before you call autoload -Uz compinit.


zstyle ':completion:*' use-compctl true
zstyle ':completion:*' verbose true
zstyle :compinstall filename "$HOME/.zshrc"

fpath=($HOME/autocomplete $fpath)

autoload -Uz compinit
# End of lines added by compinstall

You should then be able to copy your updated _git into your personal autocomplete folder, and it will be used in place of the original.

share|improve this answer
This is a lot less practical than simply making hub trigger completion for git. – mkaito Feb 1 '13 at 0:16
You wanted a way that would not get overwritten with the next zsh release. – Matthew Franglen Feb 1 '13 at 8:11
I wanted a way to trigger auto completion for one program after typing another. – mkaito Feb 2 '13 at 16:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.