How to get git flow completions for zsh working?

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.

I thought you could try this: https://github.com/Homebrew/homebrew-core/commit/f710a1395f44224e4bcc3518ee9c13a0dc850be1#r30789420

You are running macOS ? The autocompletions come with Homebrew git were conflict with the git-flow autocompletions script.

Try to remove the zsh folder in /usr/local/Cellar/git/x.xx.x/share/ and reload your zsh.

References:
1. https://github.com/Homebrew/homebrew-core/commit/f710a1395f44224e4bcc3518ee9c13a0dc850be1
2. https://github.com/bobthecow/git-flow-completion/issues/50
3. https://github.com/robbyrussell/oh-my-zsh/issues/1717

Tags:

Git

Zsh