You can customized 4 prompts: PS1 (Primary prompt, displayed before each command), PS2 (secondary prompt, displayed when command needs more input), PS3 (rarely used, displayed for Bash's select built-in which displays interactive menus).
Display current bash prompt (PS1) settings:
echo $PS1
Output: [\u@\h \W]\$
It is default settings. The backslash-escaped characters means: \u (username), \h (hostname), \W (current working directory).
To modify colors to the prompt use following syntax:
\e[x;ym $PS1 \e[m
Meaning: \e[ (start color scheme), x;y (color pair to use), $PS1 (shell prompt variable), \e[m (stop color scheme)
To set red color enter:
export PS1="\e[0;36m[\u@\h \W]\$ \e[m "
Few examples of color codes:
Setting variable PS1 is temporary, when you logout your settings will be lost. You have to append following line to $HOME/.bash_profile file or $HOME/.bashrc file:
export PS1="\e[0;36m[\u@\h \W]\$ \e[m "
Now ur new prompt color is permanent.
Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek