[pacman-dev] coloured pacman
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: not available
More information about the pacman-dev