When trying to complete for example git difftool --cached, ZSH should complete directly, but instead if gives me a lot of short options to choose from, am I doing something wrong? My current config looks like this: https://github.com/sblask/dotfiles/blob/master/zshrc.dotfile


$ git difftool --cac<TAB>
-0            -- omit diff output for unmerged entries
-1            -- diff against "base" version
-2            -- diff against "our branch" version
-3            -- diff against "their branch" version
-b            -- ignore changes in amount of white space
-B            -- break complete rewrite changes into pairs of given size
-C            -- detect copies as well as renames with given scope
--cached      -- show diff between index and named commit/
  • This works as expected for me (version 5.0.7) -- even with your zshrc. Are you using the most recent zsh version? – mpy Oct 26 '14 at 10:29
  • So git difftool --cac<TAB> completes to git difftool --cached for you? I am using 5.0.5, nothing in the release notes that points to a change that could explain it? zsh.sourceforge.net/releases.html – Sebastian Blask Oct 26 '14 at 18:50
  • Exacty, git difftool --cac<TAB> completes to git difftool --cached, see my answer for some more details. – mpy Oct 26 '14 at 21:03

If you compare the source tree of zsh-5.0.5 to the one of zsh-5.0.7, there are quite some changes regarding git completion:

$ git diff --stat zsh-5.0.5..zsh-5.0.7 | grep _git
 Completion/Unix/Command/_git                      |  353 +++--
 Functions/VCS_Info/Backends/VCS_INFO_get_data_git |  158 ++-

The release notes mention only the most important changes, but not every single code change. Here are the commit messages mentioning git (I didn't dig into which ones are relevant for your problem...):

33180: _git: add missing --3way option
33177: _git: fix typo in git-apply
33178: _git: updates for Git 2.1.0
33176: _git: Add missing --list to git-tag
33179: _git: updates for Git 2.0.0
33184: vcs_info git: consider patches for rebase
33188: vcs_info git: set rrn before using it
33150: completion git: fix send-email --confirm values
33145: vcs_info git: fix applied-string name
33147: vcs_info git: detect revert or cherry-pick with multiple commits
33151: completion git: support aliases when \n exist
33047: use git to simplify massively source distribution file selection
32662: vcs_info git: Fix stagedstr for empty repos
32597: vcs_info git: Describe detached heads symbolically.
32502: fix typo in argument list for git completio
32398: _git: completion updates up to latest git v1.9.0
32397: _git: fix __git_submodules to only use the actual name of the submodule
32395: _git: diff: refactor and fix wrong completions
32396: _git: fix __git_committish_range_{first,last} and __git_is_committish_range

I am able to reproduce the behavior you describe with zsh-5.0.5, but with zsh-5.0.7 git difftool --cac<TAB> completes as expected to git difftool --cached.

So, cut a long story short: Upgrade your installation to zsh-5.0.7.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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