It is rather an old trick – adding a color to your prompt. But it was resurrected when someone asked a question on a CentOS forum:
“how can I change color of root@localhost inside console????”
After some cheerful exchange, it turned out that this person wanted to know how to color the root’s prompt. As usual, a nice team work of regular helpers (especially between Alan and Ned) brought about colorful answers.
In fact, making the root’s prompt a colorful one is indeed a good idea. It reminds you of the root status in a much nicer way than the usual # prompt. I put in my root’s ~/.bashrc the following:
export PS1="\[\e[31;1m\][\u@\[\e[34;1m\]\H \W]# \[\e[0m\]"
This gives me [root@apollo ~]# which, in a way, has some American touch. Hmmm.
This is all good for bash. However, my own acount uses (t)csh. Not to worry. csh supports colors, too. For example, putting this line in the .login file (one line):
set prompt =
"\[%{\033[32m%}%n@%{\033[34m%}`echo $cwd`%{\033[0m%}\]$ "
produces [toracat@/home/toracat]$
I also have an alias for “cd” (one line):
alias cd 'cd \!* ; set prompt =
"\[%{\033[32m%}%n@%{\033[34m%}`echo $cwd`%{\033[0m%}\]$ "'
to get a consistent look (csh again).
Why is this good for CentOS? You can see it in the original CentOS thread:
The person who asked the question was so happy with the help he received that he decided to make a donation to CentOS. What really helped here was the “please donate” message in the Ned‘s signature. 🙂
Ok…. but how to PERMANENTLY change this ?
@John: like he says, for normal bash, just add it to the ~/.bashrc file, and it should load up when you login… to effect it immediately after editing, do a:
source ~/.bashrc