[Gllug] Coloured bash prompt
Pete Ryland
pdr at createservices.com
Thu Apr 22 15:49:41 UTC 2004
On Thu, Apr 22, 2004 at 04:24:19PM +0100, Andy Farnsworth wrote:
> -----Original Message-----
> From: Tethys
> Sent: Thursday, April 22, 2004 3:21 PM
>
> > colour1=$(tput setf 3)
> > colour2=$(tput setf 2)
> > colour3=$(tput setf 3)
> > colour4=$(tput setf 7)
>
> And even better!
>
> red=$(tput setf 3)
> blue=$(tput setf 2)
> red=$(tput setf 3)
> green=$(tput setf 7)
>
> Note that I chose the color names randomly so they probably don't
> correspond to the actual color displayed in this case.
They're just 3-bit RGB tuples. That is:
RGB
421
---
000 = 0 = black
001 = 1 = blue
010 = 2 = green
011 = 3 = cyan
100 = 4 = red
101 = 5 = magenta
110 = 6 = orange/yellow[1]
111 = 7 = gray/white[1]
> Interestingly enough, when I tried this on AIX it didn't work while the
> COLOR1="\[\033[0;36m\]" version did.
Hmm.. just had a look at the man page, and it says:
| The SVr4 documentation describes only setaf/setab; the XPG4 draft says
| that "If the terminal supports ANSI escape sequences to set background
| and foreground, they should be coded as setaf and setab, respectively. If
| the terminal supports other escape sequences to set background and
| foreground, they should be coded as setf and setb, respectively. The
| vidputs() function and the refresh functions use setaf and setab if they
| are defined."
So, perhaps it's better to use setaf instead. Note, however, that this uses
BGR order as per ANSI-sequence colours.
Pete
[1] Supposed to be yellow, but sometimes looks more like orange. There's
also a bold flag, and the "bold" version of said orange will be more like
yellow. Likewise, non-"bold" white is often gray depending on the term.
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list