csh color codes
Hannu E K Nevalainen
_garbage_collector_@telia.com
Thu Jan 29 22:48:00 GMT 2004
> From: Igor Pechtchanski
> Sent: Thursday, January 29, 2004 4:00 PM
> On Thu, 29 Jan 2004 gobo@gobo-net.de wrote:
>
> > Dear all,
> >
> > I am running the latest Cygwin on my Win2k and I'm using csh as the
> > standard shell. The color mode for XTerm is enabled and works fine, e.g.
> > with "ls --color".
> >
> > However I have a problem to figure out how to generate the appropriate
> > control (escape) sequences to included colors in shell script outputs. I
> > have some shell scripts here which originate from a HP-UX based csh.
> > There, the escape sequences are generated by pressing "Ctrl +
> V" + "Esc" +
> > "[" + 'code', where 'code' is e.g. "1m" for bold or "32m" for green (=
> > ^[[32m).
> > However, these codes don't work within the Cygwin-csh.
> >
> > Does anyone know the correct sequences here?
> > Thanks,
> > Jochen =8-)
>
> csh does nothing to interpret the sequences; it simply echoes them.
i.e. Jochen needs to find a way to get e.g. echo to actually print an ESC
where it is apropriate. NOTE, for bash:
$ /bin/echo -e "\033[36;7m Reversed colors \033[m Standard colors"
Reversed colors Standard colors
$ type -a echo
echo is a shell builtin
echo is /usr/bin/echo
echo is /bin/echo
$ echo -e "\e[36;7m Reversed colors \e[m Standard colors"
Reversed colors Standard colors
> The
> sequences are processed by the terminal program (either the console or the
> xterm). You only need to make sure the sequences are encoded correctly.
e.g. as in the /bin/echo example above...
> You might want to let some library do the encoding for you depending on
> the value of TERM...
>
> Check if the same sequences work from the HPUX bash/sh. If they do, then
> look for a problem in the way you encode the sequences in your csh
> scripts. If they don't, you're probably echoing the wrong sequences.
> Igor
Help for checking; $ man od
e.g: $ echo TEST | od -t x1z
Example of color code use from bash/rxvt:
$ echo -e "\e[7m Reversed colors \e[m Standard colors"
-- fgtab --
#!/bin/bash
echo "Foreground/Background table"
for (( f=0; f<8 ; f++ ));do
for (( b=0; b<8 ; b++ ));do
echo -en "\e[3${f};4${b}m $f/$b \e[m";
done;
echo -e "\e[m";
done
-- eof --
I'm not sure this works in anything else than a rxvt and cmd/command
*window* (ANSI.SYS activates the same for old "DOS").
I believe the codes are for some sort of ANSI terminal (I learnt them on the
Amiga
where they work in the Shell/CON window and at least in part for the
printer).
/Hannu E K Nevalainen, B.Sc. EE - 59+16.37'N, 17+12.60'E
** on a mailing list; please keep replies on that particular list **
-- printf("LocalTime: UTC+%02d\n",(DST)? 2:1); --
--END OF MESSAGE--
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list