[pacman-dev] coloured pacman

Jürgen Hötzel juergen at hoetzel.info
Tue Feb 6 15:57:47 EST 2007


On Tue, Feb 06, 2007 at 03:11:06PM -0500, Dan McGee wrote:
> On 2/6/07, Jürgen Hötzel <juergen at hoetzel.info> wrote:
> > Its not easy to display colored text in a portable way. An easy, but
> > wrong way is using ANSI escape sequences directly because you make
> > assumption about the tty.
> >
> > A much more portable way is querying the database of terminal capabilities
> > (termcap/terminfo).
> >
> > Jürgen
> 
> Much better put than my point about hardcoding the escape sequences in
> C code. Although not necessarily good in a bash script, the code can
> be edited if necessary quite easily to fix escape sequences. However,
> Jürgen makes the excellent point that these escape sequences cannot
> always be assumed to be portable.

You can also query the terminfo database in shellscripts by using ncurses
tput utility.  For example:

$ echo `tput setf 4`RED

Jürgen
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://archlinux.org/pipermail/pacman-dev/attachments/20070206/f1c98caf/attachment.pgp>


More information about the pacman-dev mailing list