[nSLUG] "Switchable" bash prompt (change color for root)

InverseCow rowan.townshend at gmail.com
Tue Mar 9 15:45:32 AST 2010


Thanks for the reply Jason. :-)

I ended up figureing this out (was a problem with the "switching" between
KSH & BASH in the environment at work).
Along the way I found some good resources if anyone else is interested in
tweaking their shells.
http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html
http://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html 
http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/
http://www.cyberciti.biz/faq/bash-shell-change-the-color-of-my-shell-prompt-under-linux-or-unix/ 
http://www.gnu.org/software/bash/manual/bashref.html#Printing-a-Prompt
http://www.gnu.org/software/bash/manual/bashref.html#Printing-a-Prompt 


Jason Kenney-2 wrote:
> 
> Years ago this was part of the default gentoo .bashrc
> 
> You can probably find a copy of that floating around if you'd like a
> more tested implementation, but there would be countless ways to do
> it:
> 
> - man whoami
> - man id
> - echo $EUID
> 
> There are many tutorials on using ascii coloring in prompts if you're
> not sure how to do that bit too.
> 
> 
> Jason
> 
> On Tue, Mar 9, 2010 at 10:22 AM, InverseCow <rowan.townshend at gmail.com>
> wrote:
>> Hi everyone, I would like to add some functionality to my .bashrc at
>> work,
>> to differentiate between when I am working as "myself" (uid=94307) and
>> when
>> I switch up to "root" (uid=0). Specifically I would like to change the
>> color
>> on my prompt to reflect the change. What would be an elegant way to
>> handle
>> this? My default shell is KSH (environmental standard), and I switch over
>> to
>> BASH before I get a prompt (minor KSH .file hack). I've attached a hacked
>> down .bashrc that I use for reference (bashrc_rowan.txt).
>> "Just because I have a burnt face, doesn't mean I can't fight crime!" --
>> http://www.burntfaceman.com/
>> ________________________________
>> View this message in context: "Switchable" bash prompt (change color for
>> root)
>> Sent from the nSLUG mailing list archive at Nabble.com.
>>
>> _______________________________________________
>> nSLUG mailing list
>> nSLUG at nslug.ns.ca
>> http://nslug.ns.ca/mailman/listinfo/nslug
>>
>>
> _______________________________________________
> nSLUG mailing list
> nSLUG at nslug.ns.ca
> http://nslug.ns.ca/mailman/listinfo/nslug
> 
> 


-----
"Just because I have a burnt face, doesn't mean I can't fight crime!" -- 
http://www.burntfaceman.com/ http://www.burntfaceman.com/ 
-- 
View this message in context: http://old.nabble.com/%22Switchable%22-bash-prompt-%28change-color-for-root%29-tp27836312p27840495.html
Sent from the nSLUG mailing list archive at Nabble.com.




More information about the nSLUG mailing list