dotfiles icon indicating copy to clipboard operation
dotfiles copied to clipboard

Switch from Zsh's git completion to Git's git completion instead

Open gabebw opened this issue 6 years ago • 0 comments

Yeah yeah, #69 happened, but:

  • This is the big one: Zsh-based git completions don't include custom git subcommands. For example, I have a git-shalector script and git sha<TAB> doesn't work with Zsh's git completions, but does work with Git's.

  • The problem in #69 was that gc was broken. I now have a custom fuzzy-finder-backed gc that I love much more than tab-completion of git branches.

  • Both Zsh and Git complete git aliases like git full, though Zsh is a little better. I'm fine with using Git's version.

    • With Zsh, git <TAB> will show the aliases along with standard subcommands, and completes them as you'd expect:
    $ git <TAB>
     #...other output...
     unpack-objects     -- unpack objects from packed archive
     unstage            -- alias for 'reset HEAD'           
     up                 -- alias for '!git fetch origin && git rebase origin/master'
    
    • With Git, git <TAB> only shows the standard subcommands. However, if I start typing a custom alias and hit tab, like git fu<TAB>, then it autocompletes as you'd expect. I always know which alias I want to use, so I'm fine typing the first bit.

For debugging, here's how to switch between completions:

  • To switch to Zsh-based completion: brew uninstall --ignore-dependencies git && brew install git --without-completions, then open a new shell
  • To switch to Git-based completion: brew uninstall --ignore-dependencies git && brew install git, then open a new shell

gabebw avatar Jun 23 '18 21:06 gabebw