2

My system's git autocompletion is pretty good, but lacks completion of at least git difftool and git diffmerge. I mean that if I type git diff<TAB> on my prompt what I get is the following:

$ g diff<TAB>
diff         -- show changes between commits, commit and working tree, etc.
diff-files   -- compare files in the working tree and the index
diff-index   -- compare content and mode of blobs between index and repository
diff-stages  -- compare two "merge states" in the index file
diff-tree    -- compare the content and mode of blobs found via two tree objects

See? No difftool or diffmerge there. I have to type them all over to the end in order to use them, or create some git alias, which I don't want.

Is there a way to patch the default git completion configuration to add support for these two commands? Where is the default git completion script? Can I modify it, or better yet, patch it in my own .zshrc or something so I don't have to mess up with the system original?

In case someone wants to know, I'm using zsh 4.3.11 on Mac Lion with the latest oh-my-zsh installed as well. My git is installed from homebrew and it's version 1.8.0.1.

Ernesto
  • 3,837
  • 6
  • 35
  • 56

1 Answers1

1

git completion is done by an autoloading function _git. You can override it.

  1. download the latest version of _git from here (use the raw link to get it).
  2. put it in a $fpath directory coming first than the path of shipped scripts. print -l $fpath will show you the list, and you can add one to the front by e.g. adding fpath=($HOME/.zsh/Completion $fpath) to your zshrc. Be sure the change of $fpath comes before compinit.
lilydjwg
  • 1,621
  • 20
  • 41
  • Neither the latest completion file above nor the [latest one shipped in git](https://github.com/git/git/blob/master/contrib/completion/git-completion.zsh) contain support for `diffmerge` yet, only `difftool`. Good opportunity for someone who wants to get a patch into zsh and/or git. – Adam Spiers Sep 30 '13 at 09:03