[Tutor] linux terminal coloring in python

wormwood_3 wormwood_3 at yahoo.com
Sun Sep 30 01:33:28 CEST 2007


Hello,

I actually wanted/looked for colored output in the CLI for quite a while myself, and finally found the solution! The magic?: "echo -e". The syntax is a little odd to use it, and I don't think I can explain it very succinctly. It may be best to see an example of it in action. I wrote a bash script to summarize files, and I used the "echo -e" syntax to color the output. 

Actual code: http://launchpod.homelinux.com:81/trac/code/browser/userextensions/summarizer.sh

Details here, with screenshots: http://assistedsilicon.blogspot.com/2007/04/summary-execution.html

Good luck!
-Sam

_____________________________________
----- Original Message ----
From: Tiago Saboga <tiagosaboga at terra.com.br>
To: tutor at python.org
Sent: Saturday, September 29, 2007 6:11:35 PM
Subject: Re: [Tutor] linux terminal coloring in python

On Sat, Sep 29, 2007 at 08:32:37AM -0700, Robert Jackson wrote:

> I'm trying to get some pretty colored output for a Linux console /
terminal window.  Google searches only reveal the curses module to
colorize output.

> Is there a simpler way?  Curses seems to be FAR too powerful for
what it is I want to do (simply to colorize a few 'print' outputs to
the console).

I have looked for that last week and the best I could find was
ColorANSI module, distributed with ipython (in a debian system, it's
/usr/share/python-support/ipython/IPython/ColorANSI.py).

I just bookmarked it, and don't know how to make it work. But it seems
quite simple.

Tiago.
_______________________________________________
Tutor maillist  -  Tutor at python.org
http://mail.python.org/mailman/listinfo/tutor





More information about the Tutor mailing list