This is the mail archive of the
cygwin
mailing list for the Cygwin project.
RE: csh color codes
- From: "Peter J. Acklam" <pjacklam at online dot no>
- To: cygwin <cygwin at cygwin dot com>, gobo at gobo-net dot de
- Date: Thu, 29 Jan 2004 15:50:27 +0100
- Subject: RE: csh color codes
>
> 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?
Why not use printf and \033 for the escape character? The
following prints "xxx yyy zzz" where "yyy" is green:
printf 'xxx \033[32myyy\033[m zzz'
Here is a list showing other escape sequences
# foreground colours
printf '\033[30m black \033[m'
printf '\033[31m red \033[m'
printf '\033[32m green \033[m'
printf '\033[33m yellow \033[m'
printf '\033[34m blue \033[m'
printf '\033[35m magenta \033[m'
printf '\033[36m cyan \033[m'
printf '\033[37m white \033[m'
# background colours
printf '\033[40m black \033[m'
printf '\033[41m red \033[m'
printf '\033[42m green \033[m'
printf '\033[43m yellow \033[m'
printf '\033[44m blue \033[m'
printf '\033[45m magenta \033[m'
printf '\033[46m cyan \033[m'
printf '\033[47m white \033[m'
# other
printf '\033[0m default \033[m'
printf '\033[1m bold \033[m'
printf '\033[2m faint \033[m'
printf '\033[3m italic \033[m'
printf '\033[4m underlined \033[m'
printf '\033[5m slowblink \033[m'
printf '\033[6m rapidblink \033[m'
printf '\033[7m negative \033[m'
Peter
--
Peter J. Acklam - pjacklam@online.no - http://home.online.no/~pjacklam
--
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/