A1.5 Appendix A: Git in Other Environments - Git in Zsh

Git in Zsh

Git also ships with a tab-completion library for Zsh.
Just copy contrib/completion/git-completion.zsh to your home directory and source it from your .zshrc.
Zsh’s interface is a bit more powerful than Bash’s:

Ambiguous tab-completions aren’t just listed; they have helpful descriptions, and you can graphically navigate the list by repeatedly hitting tab.
This works with Git commands, their arguments, and names of things inside the repository (like refs and remotes), as well filenames and all the other things Zsh knows how to tab-complete.

Zsh happens to be fairly compatible with Bash when it comes to prompt customization, but it allows you to have a right-side prompt as well.
To include the branch name on the right side, add these lines to your ~/.zshrc file:

This results in a display of the current branch on the right-hand side of the terminal window, whenever your shell is inside a Git repository. It looks a bit like this:

Figure 163. Customized zsh prompt.

Zsh is powerful enough that there are entire frameworks dedicated to making it better.
One of them is called "oh-my-zsh", and it can be found at https://github.com/robbyrussell/oh-my-zsh.
oh-my-zsh’s plugin system comes with powerful git tab-completion, and it has a variety of prompt "themes", many of which display version-control data.
An example of an oh-my-zsh theme. is just one example of what can be done with this system.