Search code examples
macosbashcommand-promptps1

Bash prompt line wrapping issue


Newbie question, I recently changed my PS1 into this:

RESET="\[\017\]"
NORMAL="\[\033[0m\]"
YELLOW="\[\033[0;33m\]"
CYAN="\[\033[0;36m\]"

export PS1="\[$RESET\]\u@\h:\[$CYAN\]\w\[$YELLOW\]\$(__git_ps1)\[$NORMAL\] \$ "

But now I get a line wrapping error. I created a gif to explain the problem:

enter image description here

Any ideas what might be wrong?


Solution

  • I think you're double-quoting your escape codes with [ and ]. Try this one:

    export PS1="$RESET\u@\h:$CYAN\w$YELLOW\$(__git_ps1)$NORMAL \$ "