Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git tab completion in zsh throwing errors

Tags:

After struggling to get tab completion for git setup on osx, I've gotten some odd errors that I can't find the source too.

zsh:12: command not found: ___main
_default:compcall:12: can only be called from completion function

I'm not sure what is causing the error as everything is setup correctly.

zstyle ':completion:*:*:git:*' script ~/.git-completion.bash
autoload -U compinit && compinit
zmodload -i zsh/complist
source ~/.git-completion.zsh

Any ideas?

like image 266
mhartington Avatar asked Jan 19 '15 16:01

mhartington


1 Answers

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.

like image 154
hchbaw Avatar answered Sep 20 '22 14:09

hchbaw