Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When working on a git repository with multiple branches, how do I modify my zsh prompt to include my current active branch?

share|improve this question
up vote 2 down vote accepted

Use the vcs_info function in the zsh user contributions (included in the zsh package). Quick start:

autoload -Uz vcs_info
precmd () { vcs_info }
setopt prompt_subst

It's likely that you'll want to make the output prettier. Since that's matter of personal taste, I refer you to the examples in the documentation.

share|improve this answer

Use oh-my-zsh. It is an auto-updating collection of several dozen plugins and themes that make zsh even better than it is already. Assuming that you have git installed already, it will automatically activate the git plugin, and then you're ready to go!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.