Saturday, October 13, 2007

Color Bash Prompt

===Color Bash Prompt===
I like to colorize my bash prompt. It's an easy way to see if you are working as your regular user or as root.
Open a terminal as your regular user, making sure you are in your home directory, and type
gedit .bashrc
Move to the bottom of the file and add this line
PS1="[\[\033[1;34m\]\u\[\033[0m\]@\h \W]\\$ "
The number 34 seen in that line gives you a blue prompt.
Save and exit the editor. Now log in as root in the terminal and make sure you are in root's home folder. Again type
gedit .bashrc
Move to the bottom of the file and add the same line that we added for regular user
PS1="[\[\033[1;31m\]\u\[\033[0m\]@\h \W]\\$ "
Left as it is, this line will give you a red prompt. Save and exit the editor.
The actual color code is "1;31" inside the PS1 variable. The 1 says make it '''bold''' and the 31 says the color red.

1;30 Black

1;31 Red

1;32 Green

1;33 Yellow

1;34 Blue

1;35 Magenta

1;36 Cyan

1;37 White (Don't think white would show up too well on this page)

Back to [[Fedora 7]]

No comments: