Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

2 Answers 2

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
PS1="\$vcs_info_msg_0_$PS1"

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

 
discard

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.