I am using macOS Big Sur Version 11.4 and just updated my .zshrc file to show git branch location on my terminal command line.
.zshrc file contains the following. I am not sure what was there before. I accidentally just created .zshrc file using touch ~/.zshrc
without checking if the file was already there. Maybe this is where things got messed up.
function parse_git_branch() {
git branch 2> /dev/null | sed -n -e 's/^\* \(.*\)/[\1]/p'
}
COLOR_DEF=$'\e[0m'
COLOR_USR=$'\e[38;5;243m'
COLOR_DIR=$'\e[38;5;197m'
COLOR_GIT=$'\e[38;5;39m'
setopt PROMPT_SUBST
export PROMPT='${COLOR_USR}%n ${COLOR_DIR}%~ ${COLOR_GIT}$(parse_git_branch)${COLOR_DEF} $ '
The git branch shows, but I noticed when I type over 28 characters on the command line, it disappears like this:
How can I fix this?