Update the .zshrc file with the following code
# Enable prompt substitution
setopt PROMPT_SUBST
# Function to fetch git branch name
git_info() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " %F{yellow}("${ref#refs/heads/}")%f"
}
# Main Prompt
PROMPT='%n@%m %F{green}%~$(git_info)%f $ '
Then, run $ source ~/.zshrc
So that you can check that the current branch will be displayed on the command line. Example