Color Bash Prompt


I like to have a blue prompt for my regular user and a red prompt for root. To accomplish this I need to edit the .bashrc file for both users. In a terminal, as regular user, edit the file.

vi .bashrc

Add the following to the bottom of the file.

PS1="[\[\033[1;34m\]\u\[\033[0m\]@\h \W]\\$ "

Save and exit. Now for the root user I need to log in as root.

su -
<password>

Then I edit root's .bashrc file.

vi .bashrc

Add the same line that was added to the regular user file making one change.

PS1="[\[\033[1;31m\]\u\[\033[0m\]@\h \W]\\$ "

Note the 1;31 in the middle of the line. This is red and will give a red prompt for root.


Return home

Color Bash Prompt (last edited 2009-09-15 08:28:17 by GlennJohnson)