[Techtalk] Console Prompt Colors

Andrea Landaker qirien at icecavern.net
Sat Apr 24 22:25:46 EST 2004


> I have a question related to the ls --colors question asked recently.
> On my Gentoo system when I'm at the console as my usual user the
> username part of the prompt is green, and when I su to root, the
> username part of the prompt changes to red.  I *like* this feature a
> bunch and would like to see it implemented on my desktop system (Fedora
> Core 1).

If you're using bash, you might want to check out my (rather large) prompt.  I 
put it in a separate file (".prompt"), and then in my .bashrc put "source 
~/.prompt".  You can see it at:
http://www.icecavern.net/~qirien/prompt
(which references another handy but unrelated script at 
http://www.icecavern.net/~qirien/cutpwd)

It wouldn't be too hard to change yours to just use green, and then change 
root's .bashrc to use red (this might not work depending on the su mode 
you're using, or which your default is).

Even if that didn't work, you could check the $USER variable in your script.

Let me know if you need anything else.  :-)

-- 
Andrea Landaker
http://www.icecavern.net/~qirien/


More information about the Techtalk mailing list