Git tab completion in zsh throwing errors

It seems that the git-completion.zsh is not designed to be sourceed. You could copy the git-completion.zsh file to somewhere in the $fpath and rename it to _git instead.

For example: (if you decide to have ~/.zsh/functions/_git.)

First, you could copy the git-completion.zsh to there and rename it to _git.

% mkdir -p ~/.zsh/functions && cp git-completion.zsh ~/.zsh/functions/_git

Then you could have your ~/.zshrc like this:

zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
# `compinit` scans $fpath, so do this before calling it.
fpath=(~/.zsh/functions $fpath)
autoload -Uz compinit && compinit

If I’m not sure, I do rm ~/.zcompdump to make sure that compinit discards its cache.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)