Color your Bash Prompt, 16M edition!
#OPTIONS: toc:nil
How to color the Bash prompt
I have revised the script to color my bash prompt, which now manages
colors expressed as R;G;B
, in terminals which support 16M colors.
To make it short (after all, you need some time to try all 16M colors, don’t you?):
- Here you can find the quick explanation on how to set the prompt: color-bash-prompt
- List of escape codes (look for “Font Effects”): https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
- The need for
\[...\]
to make sure the cursor homes right is explained here: Custom Bash Prompt Cursor Positioning Issue.
and here you can find the script here: color-bash-prompt-16M.
Some examples:
$ cat bash_prompt.sh # so that you know what it does $ source bash_prompt.sh $ list_colors ... $ set_prompt_color --256 255 # quotes are important since ; separates commands $ set_prompt_color --16M "255;120;120"
You can use a third argument to set the background color as well.