Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I customized my bash PS1 prompt with this ~/.bashrc file. I can't seem to figure out why my output colors change after the first 2 lines of output.

bash output

Any ideas what could be causing the issue?

share|improve this question
up vote 2 down vote accepted

The problem seems to be that there is no escape sequence to reset the colors at the end of the prompt, so the command text is also colored because the interpreter don't know where to stop coloring. You need to append this escape sequence at the end of your prompt \[\033[0m\]. So your prompt sequence would be something like:

"${USER_COLOR}\u${WHITE}@${SYSTEM_COLOR}\h ${CYAN}\w ${RED}"'$(rvm_prompt)'"${GREEN}"' $(__git_ps1 "(%s)") '"${WHITE} $\[\033[0m\] "

You can associate this sequence with a variable, add it to the prompt function definition and use it as with the other color definitions:

local RESET="\[\033[0m\]"

Thus, the prompt would be:

"${USER_COLOR}\u${WHITE}@${SYSTEM_COLOR}\h ${CYAN}\w ${RED}"'$(rvm_prompt)'"${GREEN}"' $(__git_ps1 "(%s)") '"${WHITE} $${RESET} "

For further reading you should check out the Color Bash Prompt Arch Wiki article.

share|improve this answer

Because ls is using --color=..., and sending esc controls to remove colors at line end.

try it: ls -l --color=none, the chars will be all white.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .