The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: Grant Taylor <gtaylor@tnetconsulting.net>
Cc: cctalk <cctalk@classiccmp.org>, tuhs@minnie.tuhs.org
Subject: Re: [TUHS] Seeking wisdom from Unix Greybeards
Date: Wed, 25 Nov 2020 19:00:48 +0100	[thread overview]
Message-ID: <20201125180048.IvtOI%steffen@sdaoden.eu> (raw)
In-Reply-To: <9c1595cc-54a1-8af9-0c2d-083cb04dd97c@spamtrap.tnetconsulting.net>

Grant Taylor wrote in
 <9c1595cc-54a1-8af9-0c2d-083cb04dd97c@spamtrap.tnetconsulting.net>:
 |Hi,
 |
 |As I find myself starting yet another project that that wants to use 
 |ANSI control sequences for colorization of text, I find myself -- yet 
 |again -- wondering if there is a better way to generate the output from 
 |the code in a way that respects TERMinal capabilites.
 |
 |Is there a better / different control sequence that I can ~> should use 
 |for colorizing / stylizing output that will account for the differences 
 |in capabilities between a VT100 and XTerm?
 |
 |Can I wrap things that I output so that I don't send color control 
 |sequences to a TERMinal that doesn't support them?

  color_init() {
     [ -n "${NOCOLOUR}" ] && return
     [ -n "${MAILX_CC_TEST_NO_COLOUR}" ] && return
     # We do not want color for "make test > .LOG"!
     if (command -v stty && command -v tput) >/dev/null 2>&1 &&
           (<&1 >/dev/null stty -a) 2>/dev/null; then
        { sgr0=`tput sgr0`; } 2>/dev/null
        [ $? -eq 0 ] || return
        { saf1=`tput setaf 1`; } 2>/dev/null
        [ $? -eq 0 ] || return
        { saf2=`tput setaf 2`; } 2>/dev/null
        [ $? -eq 0 ] || return
        { saf3=`tput setaf 3`; } 2>/dev/null
        [ $? -eq 0 ] || return
        { b=`tput bold`; } 2>/dev/null
        [ $? -eq 0 ] || return

        COLOR_ERR_ON=${saf1}${b} COLOR_ERR_OFF=${sgr0}
        COLOR_WARN_ON=${saf3}${b} COLOR_WARN_OFF=${sgr0}
        COLOR_OK_ON=${saf2} COLOR_OK_OFF=${sgr0}
        unset saf1 saf2 saf3 b
     fi
  }

Is what i use for a make system.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)

  parent reply	other threads:[~2020-11-25 18:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-25 17:14 Grant Taylor via TUHS
2020-11-25 17:22 ` Ralph Corderoy
     [not found]   ` <20201126145134.GB394251@mit.edu>
2020-11-26 21:48     ` steffen
2021-02-10 18:57       ` Greg A. Woods
2021-02-10 22:26         ` Clem Cole
2021-02-24 22:20         ` Steffen Nurpmeso
2020-11-26 21:59     ` dave
2020-11-25 17:38 ` Larry McVoy
2020-11-25 18:00 ` Steffen Nurpmeso [this message]
2020-11-25 20:03   ` Steffen Nurpmeso
     [not found] ` <CACYmRNAtdJu0ui=CgrEcWH6J3uikCh0=aCLNvk0+V29rypDBAg@mail.gmail.com>
     [not found]   ` <71fdfa2e-1483-4985-3f55-6760b3a84ec0@gmail.com>
     [not found]     ` <20201126182937.GN9589@mcvoy.com>
2020-11-26 23:14       ` erc
2020-11-26 23:23         ` lm
     [not found] <20201126183746.DD93218C087@mercury.lcs.mit.edu>
     [not found] ` <7DBB40AE-259D-494E-8ABF-2FE4D47F4052@iitbombay.org>
2020-11-26 19:02   ` lars
2020-11-26 21:56   ` steffen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201125180048.IvtOI%steffen@sdaoden.eu \
    --to=steffen@sdaoden.eu \
    --cc=cctalk@classiccmp.org \
    --cc=gtaylor@tnetconsulting.net \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).