On Thursday 23 March 2006 15:07, Jules Colding wrote:
> > I used to give the shell prompts different colours on different
> > machines to help avoid this. Or rather, the local one would always be
> > the same colour, but shells under ssh sessions were colour-coded by
> > machine.
> >
> > I've lost the script I wrote for this somewhere in the mists of time
> > (if I remember right, it was copied and hacked from a bash prompt
> > example that colour-coded according to the login type: ssh, telnet,
> > local, etc.)
> >
> > Someday I might get round to recreating it...
>
> That would be helpful.

Here is an example that you could put in your .bashrc:

# Is this an ssh connection?
if [[ ! -z ${SSH_TTY} ]]; then
        # Set prompt to \green([EMAIL PROTECTED]) \blue($PWD \$) green(..
        PS1='\[\033[01;[EMAIL PROTECTED] \[\033[01;34m\]\w \$ \[\033[01;32m\]'
# Not an ssh connection
else
        # Set prompt to \green([EMAIL PROTECTED]) \blue($PWD \$) black(..
        PS1='\[\033[01;[EMAIL PROTECTED] \[\033[01;34m\]\w \$ \[\033[00m\]'
fi

If you want other colors or whatever refer to man console_codes.

-- 
Bo Andresen
-- 
gentoo-user@gentoo.org mailing list

Reply via email to