I would like to see errors in my terminal colorfully, similarly as here: http://stackoverflow.com/questions/452532/what-does-this-python-message-mean
views:
322answers:
3IPython will syntax-highlight Python code and stacktraces, as in the example you give (which is, in fact, a Python stack trace).
The example you link to was not actually syntax-highlighted on the user's console, or with support from their shell, but rather highlighted by the Stack Overflow website after upload.
If you want a newbie-friendly UNIX shell which does some level of general-purpose syntax highlighting, I recommend the fish shell.
Try this sample Perl script:
use Term::ANSIColor;
print "Hello "
.color("green")
."world"
.color("reset")
."\n"
or as a shell one-liner:
perl -e 'use Term::ANSIColor; print "Hello ".color("green")."world".color("reset")."\n"'
Note that you need to have the Term::ANSIColor module installed.
Unfortunately, there is no perfect general solution. But there are a few general ways that work.
GRC, stands for Generic Colouriser and is for beautifying your logfiles or output of commands. It's packaged on major distributions. I've used it to colorize my make output very nicely. GRC is usually used for common commands with aliases like "grc comand". There are other colorisers and websites sometimes have their own unique ones.
A great many programs use the conventional command line switch --color=auto. --color=always will make color happen even from a non-interactive shell, which can be nice to look at later for logged comands using terminal code aware commands like less -R.
If your text is from any half-way known program and is ever logged or stored in a file, the text editors Vim or Emacs can do some very smart highlighting on it. Other editors/ides can too but none are as comprehensive. They have general highlighting schemes for configuration files as well as specific filetypes that get very obscure, such as "Quake[1-3] configuration file". And of course there are many many color schemes for each editor to change the colors of hightlighted areas recognized by the editor. This is probably the method most used to get really good highlighting.
Of course there are ways to manually type colors in your terminal, with tput or the actual escape codes, and individual programs like ipython or whatever. You didn't ask that question, but you've chosen an answer like that as your favorite solution :(
A general solution you might expect would be to colorize standard error in your terminal. Unfortunately there is no way to do this because of lots of complications, for example your prompt is sent to standard error.