live and learn

Bruce Dubbs bruce.dubbs at gmail.com
Fri Jun 11 12:36:38 PDT 2010


Aleksandar Kuktin wrote:
>> On Fri, 11 Jun 2010 13:16:24 -0500
>> Mike McCarty <Mike.McCarty at sbcglobal.net> wrote:
>>
>> Use a red colored prompt when running with root authorization.
>>
>> Hope you keep learning for a long time.
>>
>> Mike
> 
> See, this is a good point. :)
> 
> I should fix this on my system.

You might try this:

Put this in /etc/profile and ~/.bashrc

if [ -f /etc/bashrc ]; then
         . /etc/bashrc
fi

And this in /etc/bashrc

NORMAL="\[\e[0m\]"
RED="\[\e[1;31m\]"
GREEN="\[\e[1;32m\]"
if [[ $EUID == 0 ]] ; then
   PS1="$RED\u$NORMAL@$HOSTNAME$RED [ $NORMAL\w$RED ]# $NORMAL"
else
   PS1="\u$GREEN@$HOSTNAME$GREEN [ $NORMAL\w$GREEN ]\$ $NORMAL"
fi

   -- Bruce



More information about the lfs-support mailing list