I'm trying to set the color of my git branch name and path in my terminal, but keep the rest of the text standard in the theme. The problem I have is that I was able to change the color of my git branch, but it also now changes the color of everything I'm typing in terminal to the same color as the git branch. I believe the problem is that in my prompt command the text isn't escaped correctly. How can I fix this?
# Find and set branch name var if in git repository.
function git_branch_name()
{
branch=$(git symbolic-ref HEAD 2> /dev/null | awk 'BEGIN{FS="/"} {print $NF}')
if [[ $branch == "" ]];
then
:
else
echo '- ('$branch')'
fi
}
# Enable substitution in the prompt.
setopt prompt_subst
COLOR_DIR=$'\e[1;32m'
COLOR_GIT=$'\e[38;5;39m'
# Config for prompt. PS1 synonym.
prompt='%2/ ${COLOR_GIT}$(git_branch_name) > ' (I believe the problem is here)