Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable git file tab completion with zsh compinit?

I have a problem with the zsh tab completion: After running:

autoload -U compinit
compinit

Git tab completion for files does not work any more. For example if I type git add my_f to complete my_file, nothing happens. The zsh git completion only seems to work for git branches and tags.

Without the compinit stuff, git file completion works, but of course I'm missing out all the fancy branch completion stuff.

So... Is there a way to make git file completion AND git branch completion possible at the same time in zsh? This would really help me a lot.

like image 276
Ralph von der Heyden Avatar asked Oct 29 '09 10:10

Ralph von der Heyden


1 Answers

(I'm adding an answer here mostly to get it off the unanswered list.)

As you can see from the comments, it does work. I believe the whole zsh situation has recently improved significantly, too:

commit 06f44c3cc5ca5eca638f300a518c65aa98d26d6d

Date: Mon Sep 6 08:33:19 2010 -0400

completion: make compatible with zsh

Modify git-completion.bash so that it also works with zsh when using bashcompinit. ...

So, if you happen across this googling, and your completion isn't working, try upgrading your git-completion.bash (link points to the blob from git.git HEAD). Current git version is 1.7.3.2; it should make it into the next one.

like image 62
Cascabel Avatar answered Sep 27 '22 23:09

Cascabel