[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Shell prompts (was Re: floppy permissions)



on Wed, Apr 18, 2001 at 04:07:38PM -0500, will trillich (will@serensoft.com) wrote:
> On Wed, Apr 18, 2001 at 12:48:55AM -0700, Karsten M. Self wrote:
> > Not half bad.  My own approach is slightly more subtle, but reasonably
> > effective:
> > 
> >     function proml
> >     {
> >     case $TERM in
> > 	xterm*|rxvt|eterm|wterm)
> > 	    local TITLEBAR='\[\033]0;\u@\h:\w\007\]'
> > 	    ;;
> > 	*)
> > 	    local TITLEBAR=''
> > 	    ;;
> >     esac
> > 
> >     PS1="${TITLEBAR}\
> >     [\[\033[7m\]\u\[\033[0m\]@\h:\W]\
> >     \$ "
> >     PS2='> '
> >     PS4='+ '
> >     }
> > 
> >     proml
> >     unset proml
> >     export PS1
> > 
> > This results in a highlighted prompt for root (the escape sequences),
> > while my standard prompt is just plaintext.
> 
> <confrontation mode=head-butt>oh yeah? looks to me like this only checks
> whether you're running under an X-window *term versus the console, not whether
> you're logged in as root. aha! gotcha!</confrontation>

Actually, you're right, and I probably should have mentioned same.  I
have different .bashrc files for root and non-root users.  Typically,
you'll want this as other aspects of root and normal user login/init
sequences change as well.  The code demonstrates highlighting, not
conditional user testing.

The terminal code is in both instances (root/non) to create a variable
titlebar text for window title bars when running under X.

> here's my iteration on top of your stuff, and <flameproof suit at hand> please
> feel free to gimme pointers on how to make this (particularly colors) more
> modular...

<code snipped>

One option would be to define a list of colors, then assign a color to,
say, $REAL_PROMPT_COLOR, or something like.

-- 
Karsten M. Self <kmself@ix.netcom.com>    http://kmself.home.netcom.com/
 What part of "Gestalt" don't you understand?       There is no K5 cabal
  http://gestalt-system.sourceforge.net/         http://www.kuro5hin.org

Attachment: pgp6waQ6XW7mn.pgp
Description: PGP signature


Reply to: