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.
Any ideas what could be causing the issue?
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.
Any ideas what could be causing the issue?
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.
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.