2

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?

1

1 Answer 1

-1

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.

Example:

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

fpath=($HOME/autocomplete $fpath)

autoload -Uz compinit
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.

3
  • This is a lot less practical than simply making hub trigger completion for git.
    – mkaito
    Feb 1, 2013 at 0:16
  • You wanted a way that would not get overwritten with the next zsh release. Feb 1, 2013 at 8:11
  • I wanted a way to trigger auto completion for one program after typing another.
    – mkaito
    Feb 2, 2013 at 16:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .