Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] sed and ANSI sequences



On Thu, Oct 13, 2011 at 3:00 PM, David Kramer <david at thekramers.net> wrote:
> I have a script at work that colorizes command outputs. ?I've mentioned it here before. ?I have
> the colors defined in environment variables:
> COLOR_ERROR='\e[37;41m'
> COLOR_GOOD='\e[32;40m'
> COLOR_RESET='\e[0m'
> COLOR_WARN='\e[33;40m'

Have you considered using the tput command to get the appropriate
sequences for whatever terminal you are on rather then hardcoding
them?  I've only used it to "standout" text, but the terminfo(5)
manual page implies there is support for color as well.

I've used

SMSO="`tput smso`"
RMSO="`tput rmso`"

to get the sequences to get in and out of standout (reverse video)
mode.  I was able to coax some color sequences out of tput pretty
quickly, but the documentation is pretty baroque and I don't know if
you will be able to get exactly what you have now or not.

Good Luck,
Bill Bogstad



BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org