Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

2 Answers 2

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
add comment

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.