Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2002 01:32:46 -0600 (CST)
From:      Ryan Thompson <ryan@sasknow.com>
To:        Andre` Niel Cameron <AndreC@Axxs.net>
Cc:        <questions@FreeBSD.ORG>
Subject:   Re: Collor trouble 
Message-ID:  <20020105012322.P91379-100000@catalyst.sasknow.net>
In-Reply-To: <0dd101c19593$64c3cfd0$a50410ac@olmct.net>

next in thread | previous in thread | raw e-mail | index | archive | help
Andre` Niel Cameron wrote to questions@FreeBSD.ORG:

> Can anyone point me to a good reference to control colors in a
> bash shell? I need to change and set some collors and I have no
> clue how to do it:(

Assuming you want to know how to colorize your prompt, all you really
need is a decent ANSI color reference, and a bit of knowledge on how
bash operates.

Use the \e escape code in bash to generate the ANSI escape code. From
there, the rest is all ANSI. I'd really rather not post an exhaustive
list of codes, but look for stuff like \e[1;35m, and think bright
purple :-) As mentioned, a decent ANSI reference (I used to have one
that fit on a business card) will tell you everything you need to
know.

Also, in bash, you'll want to use the special bash constructs to
escape your pure ANSI sequences so that bash can still calculate the
displayed length of your prompt. Use \[ and \] at the start and end of
each ANSI code.  For example,

Do it with \[\e[0;31m\]color.

It'll display otherwise, but bash won't handle the end of the line
properly if you omit the \[ \] bit.

- Ryan

-- 
  Ryan Thompson <ryan@sasknow.com>
  Network Administrator, Accounts

  SaskNow Technologies - http://www.sasknow.com
  #106-380 3120 8th St E - Saskatoon, SK - S7H 0W2

        Tel: 306-664-3600   Fax: 306-664-1161   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020105012322.P91379-100000>