git completion in zsh

Just figured out how to get git tab completion working in zsh on a Mac. Turns out that the completion scripts use a bunch of extra git commands such as git-ls-files. These commands need to be in your path for the completion to work. If you installed git using the OS X installer, you need to add this directory to your path:

/usr/local/git/libexec/git-core

3 Comments

  1. Bjørn Arild Mæland:

    Thanks for posting, this fixed my problem. :)

  2. GJ:

    Just what I was look for, great :)

  3. Arild Shirazi:

    Thanks a bunch! Not having completion was driving me crazy.

    Since this is for Mac OS X, I thought I would pass along another tip for adding to the PATH. /usr/libexec/path_helper looks for files in /etc/paths.d and appends their contents to the PATH.

    Thus to get git tab completion on my Mac:
    echo “/usr/local/git/libexec/git-core” | sudo tee -a /etc/paths.d/git

Leave a comment