I run the following codes separately as my prompt unsuccessfully in .zshrc. This suggests me that apparently I do not have a program called __git_ps1. It is not in MacPorts.
I just redid mine since we have long branch names at work. This one will truncate with an ellipsis if it's more than 35 characters.
parse_git_branch() {
git_status="$(git status 2> /dev/null)"
pattern="On branch ([^[:space:]]*)"
if [[ ! ${git_status} =~ "(working (tree|directory) clean)" ]]; then
state="*"
fi
if [[ ${git_status} =~ ${pattern} ]]; then
branch=${match[1]}
branch_cut=${branch:0:35}
if (( ${#branch} > ${#branch_cut} )); then
echo "(${branch_cut}…${state})"
else
echo "(${branch}${state})"
fi
fi
}
setopt PROMPT_SUBST
PROMPT='%{%F{blue}%}%9c%{%F{none}%}$(parse_git_branch)$'
(I'm embarrassed at how proud I am of this.)