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

I have git and git-flow installed via Homebrew. I am on a Mac.

I have zsh 5.0.2 (x86_64-apple-darwin12.4.0)

git completions are working. git-flow completions are not.

I cannot get git flow completions to work.

I've tried two ways to install the functions.

Method 1

I installed git-flow using Homebrew, which added the functions to this directory /usr/local/share/zsh/site-functions

That path is in my $fpath

> echo $fpath
/usr/local/share/zsh/site-functions /usr/local/Cellar/zsh/5.0.2/share/zsh/functions

Method 2

I downloaded the git-flow completion functions from and put the file in ~/.zsh/completions.

I then added the directory to my ~/.zshrc

fpath=(~/.zsh/completions $fpath)

> echo $fpath
/Users/jord/.zsh/completions /usr/local/share/zsh/site-functions /usr/local/Cellar/zsh/5.0.2/share/zsh/functions

Neither of these methods works.

What am I doing wrong?


The output of git-flow [CTRL+X] [h] is:

> git flow
tags in context :completion::complete:git::
    all-files  (_files _default _git (eval))


It's working!

I put the _git functions from the URL provided by @mpy in ~/.zsh/completions/ and added ~/.zsh/completions to my $fpath in ~/.zshrc.


I then downloaded git-flow-completion.zsh from and put it into ~/.zsh/completions and sourced that file from my .zshrc.

git and git flow completions are now working, but I have no idea why?!

share|improve this question
Both methods should be fine. As it is working here and just to make sure: Did you start a new zsh instance after putting the file into $fpath? And, can you please post the output of git-flow [CTRL+X] [h]? – mpy Jul 24 '13 at 22:27
I've updated my post with the output. I assume this means it can't find the git-flow completions, only the git completions? – jordelver Jul 25 '13 at 8:50
I wrote an answer, although I don't have a solution. But perhaps one of my ideas for troubleshooting will help -- and I couldn't fit everything into a comment ';)' – mpy Jul 25 '13 at 11:35
up vote 1 down vote accepted

The file $fpath/_git-flow provides completion for git-flow (with dash), see its first line:

#compdef git-flow

So, using git-flow [CTRL+X] [h] I get

$ git-flow [CTRL+X] [h]
tags in context :completion::complete:git-flow::
    argument-1  (_arguments _git-flow)
tags in context :completion::complete:git-flow:argument-1:
    commands  (_describe _git-flow)

showing that zsh detects that the prompt is now at the first argument to git-flow.

The completion function for git is very powerful (and to be honest, I cannot ,,read'' it through), so also git flow (w/o dash) provides the git-flow completion, but the context is different:

$ git flow [CTRL+X] [h]
tags in context :completion::complete:git::
    argument-rest  (_arguments _git)
tags in context :completion::complete:git-flow::
    argument-1  (_arguments _git-flow _call_function _git)
tags in context :completion::complete:git-flow:argument-1:
    commands  (_describe _git-flow _call_function _git)

If using a non existent git module, I end up with

$ git foo [CTRL+X] [h]
tags in context :completion::complete:git::
    argument-rest  (_arguments _git)
tags in context :completion::complete:git-foo::
    directories    (_files _git) 
    globbed-files  (_files _git) 
    all-files      (_files _git)

which looks closest to your result.

Therefore my suggestions would be:

  • check your _git-flow completions file isn't corrupted and has the right line endings (EOL)
  • trigger completion for git-flow with e.g. git-flow [CTRL+X] [h] and have a look at the output of which _git-flow:

    • if the completion function cannot be read this results in

      $ which _git-flow
      _git-flow () {
              # undefined
              builtin autoload -XUz
    • if read correctly you get the function printed:

      $ which _git-flow
      _git-flow () {
          local curcontext="$curcontext" state line
          typeset -A opt_args
          _arguments -C ':command:->command' '*::options:->options'
  • try to compile the _git-flow function file with zcompile _git-flow to see if there will be an error. (Then the resulting file _git-flow.zwc should be read upon autoloading.)

  • examine ~/.zcompdump if the _git-flow completion is listed.
share|improve this answer
Thanks for the useful answer. If I compile the function file with zcompile the completions show up, but only for git-flow not git flow. Why is it necessary to compile the functions? And how can I get it working for git flow? – jordelver Jul 25 '13 at 12:53
@jordelver: Frankly, I don't know, why it's working when compiled. That shouldn't matter. Do you have the up-to-date version of the _git completion? If there is a older version of _git somewhere in your $fpath things might get screwed up. Try to compile _git as well?! – mpy Jul 25 '13 at 14:39
If I have two versions of the functions which take precedence? I have a _git file in /usr/local/share/zsh/site-functions AND in /usr/local/Cellar/zsh/5.0.2/share/zsh/functions. Once is the default zsh install, one is installed by the git Homebrew package :| And, they are different, one seems to be zsh script only and the other uses the bash completions :/ – jordelver Jul 25 '13 at 15:12
@jordelver: I don't know what happens with two identical named files, but it sounds like a source of irritations. Try to move both files out of $fpath and put only the official _git function from… into $fpath. – mpy Jul 25 '13 at 15:21
Ok, it's working! But I don't have any idea why ;) See my update at the top. I don't understand why I have source files when there seems to be an _ convention, but anyway, it's working. Thank you very much for your help :) – jordelver Jul 25 '13 at 16:59

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.