delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/01/29/09:51:11

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-WebMail-UserID: pjacklam AT online DOT no
Date: Thu, 29 Jan 2004 15:50:27 +0100
From: "Peter J. Acklam" <pjacklam AT online DOT no>
To: cygwin <cygwin AT cygwin DOT com>, gobo AT gobo-net DOT de
X-EXP32-SerialNo: 50000140
Subject: RE: csh color codes
Message-ID: <401C1463@epostleser.online.no>
Mime-Version: 1.0
X-IsSubscribed: yes

>
> 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 AT online DOT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019