[TAG] 2-cent Tips: Same prompt different term

Thomas Adam thomas.adam22 at gmail.com
Wed Oct 25 23:42:57 MSD 2006


On Wed, Oct 25, 2006 at 08:34:23PM +0100, Martin Hooper wrote:
> Andrew Elian wrote:
> > Hello.
> > 
> > Here's a quick tidbit to help the PS1 variable do the right thing
> > depending on the terminal - X or otherwise.  I've added these lines to
> > my .bash_profile and found them useful:
> 
> On the same note how would you find out wether you were logged in 
> as root or not?
> 
> Basically I want to do the same as Andrew but based on what the 
> user was logged in as.

``
[ "$(id -u)" == 0 ] &&
{
    # Do stuff as root
} || {
  # Do stuff as normal user
}
''

-- Thomas Adam

-- 
"Wanting to feel; to know what is real.  Living is a lie." -- Purpoise
Song, by The Monkees.





More information about the TAG mailing list