How to set the command prompt's color in Bash?
Browsing the last command's results in Bash is a bit hard because the command prompt and results are the same color. This makes it hard to separate the results of consecutive commands.
How do I change the color to pink for example?
@Rob is right; specifically, to change to light red (pink is not an available color):
PS1 = "\[\033[1;31m\]\u:\w\$\[\033[0m\] "
# ^^^^^^^ ^^ Begin/end ANSI escape
# ^^^^^ "light red foreground"
# ^^^^^^^ Your original prompt
# ^^^^^^^^^^^ Reset color back to default foreground
You need to use ANSI escape sequences (in this case 1;31m
, the code for "light red foreground") which are enclosed by \[\033[
and \]
.
Edit: Light purple may be closer to your desired color; the PS1
change is left as an exercise for the reader.
reference @ the linux documentation project