I cannot get git completion to work on my freshly installed OS X Yosemite in the zsh shell. I've installed both git and zsh using homebrew:
brew install zsh git
When installing git via homebrew, it should setup tab-completion for you, but when I git <tab>
, it just tries to tab-complete the directories, and not the git-commands. I.e. it's not giving any errors - it's just not working - like it's not set up.
This is what I know so far
Apparently zsh will look for ways to autocomplete by looking for _*
files in one of the directories in $fpath
. This is mine:
% echo $fpath
/usr/local/share/zsh/site-functions /usr/local/Cellar/zsh/5.0.6/share/zsh/functions
Looking at the first path we see:
% ls -l /usr/local/share/zsh/site-functions
lrwxr-xr-x 1 watson admin 55 Oct 20 12:08 _git -> ../../../Cellar/git/2.1.2/share/zsh/site-functions/_git
lrwxr-xr-x 1 watson admin 70 Oct 20 12:08 git-completion.bash -> ../../../Cellar/git/2.1.2/share/zsh/site-functions/git-completion.bash
So it seems to be setup to work out of the box - but it doesn't.
This is what I've also tried
git-completion.bash
- Downloading git-completion.bash
- Running it using
source git-completion.bash
This one kind of works (i.e. it enables auto-completion), but it prints a warning:
WARNING: this script is deprecated, please see git-completion.zsh
git-completion.zsh
So because of the above warning, I obviously also tried to download git-completion.zsh and followed the guide in the top of the file, but it basically tells you to source the .bash file first, which is of cause still giving an error.
Search StackOverflow and Google
I've tried just about everything I could find by searching here and on Google, but nothing seems to work for me.
git-completion.zsh
script doesn't tell you to source the .bash file, the script does it by itself, it only needs to know the location. Since you have both files in the same directory that's all you need. – Offish