ZSH and git branches

I recently stumbled over a nice code snippet for my .zshrc which shows the current branch in a git repository on the right prompt:

git_prompt_info() {
ref=$(git-symbolic-ref HEAD 2> /dev/null) || echo “”
echo ” (${ref#refs/heads/})”
}

setopt prompt_subst
RPROMPT=’$(git_prompt_info)’

Leave a Reply