On Wed, 23 Jul 2003, David selby wrote:
I am trying to get my bash scripts to highlight some of their output in
colour, a bit like ls --color
It seems that I have to use ANSI esc sequences ...
man xterm ..
SEE ALSO
resize(1), X(7), pty(4), tty(4)
Xterm Control Sequences (this is the file ctlseqs.ms).
http://dickey.his.com/xterm/xterm.html
I cant find the control sequences document ctlseqs.ms, though I have
searched the system as root for it.
I think I found it in /usr/share/doc/xterm not too long ago. Let me
check...
$ ls /usr/share/doc/xterm
README.Debian ctlseqs.ps.gz xterm.faq.text.gz
xterm.terminfo.gz
changelog.Debian.gz ctlseqs.txt.gz xterm.log.html
copyright xterm.faq.html xterm.termcap.gz
I did a lot of testing with ANSI sequences when writing TERM::ANSIMenu
and found that even though a lot of terminals say they are VT100
compliant (including the ANSI stuff), most of them do have some issues.
I am no KDE fan (I like it lean and mean, like windowmaker, but that's
another topic) but I must say that konsole did earn some credits in my
book during those tests. I seem to remember that xterm had trouble with
BLINK, if I am not mistaken it showed up as BOLD. If you want a full
list of all sequences that I did get working on most of them let me know
and I'll extract them from the perl code for you. Maybe the text below
is useful to you. I found it somewhere on the net:
ANSI Terminal Codes
Here is the format of ANSI screen codes:
[ <Text Attribute> ; <Foreground Color> ; <Background Color> m
Text Attributes
*0 - All attributes off
1 - Bold
*
5 - Blinking
*
*7 - Reverse
*8 - Hidden
Foreground colors
30 - Black
*
*31 - Red
*32 - Green
*33 - Yellow
*34 - Blue
*35 - Magenta
*36 - Cyan
*37 - White
Background colors
*40 Black
*44 Blue
*41 Red
*45 Magenta
*42 Green
*46 Cyan
43 Yellow
*
47 White
*
Before the [A;B;Cm you need an escape prefix. You can type it in each time
you need it. I only know how to make the escape prefix using vi. It is 4
characters. They are ^v ^_ ^v ^[ (the ^ means the control key). On joe the
escape sequence is ^_^[. To save typing you can put this prefix in a file
and paste it when needed. Using Pico this is done using "^r". Here's an
example of a flashing white "hello" on a red background:
^v^_^v^[[5;37;41mhello^v^_^v^[[0m. On the right side of the sequence the
"[0m" resets the colors so the rest of the screen doesn't blink white on
red. All ansi sequences ( like [1;37;41m or [0m ) need to be preceded by
the escape prefix. When posting an article and you are prompted for a
subject you can type just anything. When you are then in edit mode you go
to the subject line and erase whatever you just typed in and replace it
with your ansi text. The escape prefix must be typed in using vi. You can
create it using vi and put in a file and then paste it using whatever
editor you want.
HTH