autoload -Uz compinit && compinit
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_GIT=$'%F{39}'
COLOR_DEF=$'%f'
setopt PROMPT_SUBST
export PROMPT='%~${COLOR_GIT} $(parse_git_branch)${COLOR_DEF}$ 'Restart the shell or reload the profile by running source ~/.zshrc.
Based on this gist by reinvanoyen.
