Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I configure zsh to autocomplete branch names while using 'git checkout'?

When I say 'git checkout ' I want zsh to autocomplete names of my git branches. Is that possible?

like image 957
Shashank Pandit Avatar asked Apr 22 '10 20:04

Shashank Pandit


People also ask

How does git autocomplete work?

This feature is a must-have if you work with long branch names. For example, if you typed git checkout ma and then pressed the Tab key, git tab autocomplete would automatically fill in the rest of the branch name, like this: git checkout main .

What is git-completion zsh?

Configuring the Shell fpath : The git-completion. zsh is a function file, not designed to be sourced like the bash script. This command appends the ~/. zsh directory onto the shell's function lookup list.


2 Answers

I got git autocomplete to work in zsh by adding this to my .zshrc:

autoload -Uz compinit && compinit

Credit: https://stackoverflow.com/a/67627099/480608

like image 91
Raine Revere Avatar answered Oct 05 '22 23:10

Raine Revere


The easiest way (and probably the only one not requiring a serious amount of hacking) is to update zsh. On my zsh 4.3.9 autocompletion works for git branches.

like image 36
Jawa Avatar answered Oct 05 '22 23:10

Jawa