[IPython-dev] grin and ansi escapes

tfetherston@ao... tfetherston@ao...
Wed Mar 17 00:52:48 CDT 2010

grin is a grep-like python utility that can mine files/directories via regexes and output its result colorized by ansi escapes.  If you have it installed you can use it in IPython with the system command escape:

!grin <regex> <file/directory>

On linux and Mac this probably is enough to get you colored output as those terminals recognize ansi escapes which grin should generate as it has some awareness of that capability.  However, windows doesn't have that capability built in, the pyreadline utility adds it, but it must be told to interpret the ansi escapes.

Here is how I got colored output on windows:

from IPython.genutils import Term

oc = !grin hi "C:\PyDevArea\IPy-repo\0.11DemoFix\docs\examples\lib" --force-color
print >> Term.cout, oc.n

I'd like to make this simpler, use an alias, custom magic, add a util to handle output expected to be ansi escape colorized?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-dev/attachments/20100317/4dd409bc/attachment.html 

More information about the IPython-dev mailing list