Bash prompt in OS X terminal broken

bash, macos, unix

Solution

You need the [ and ] arond every escape sequence; do $BLUE and the like include these? If not, they need to be bracketed with these calls.

Problem

I am using bash in os X Terminal app, and my custom $PS1 breaks when I scroll through my history. ``` PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\n\[${red}\$${NC}\]" ``` also tried PS1="${BLUE}\u${CYAN}@${RED}\h${BLUE}\w\r\n[${red}\$${NC}]" The problem seems to be in the newline. I have used this bash prompt on Slackware no prob.

Original source