How can I colorize code sent to STDOUT?

view story

http://askubuntu.com – Most text editors - vim, emacs, kate, gedit - have colorizers, so that, depending on the language you're programming in, it will color the text differently. Is there a way to do that for code sent to the STDOUT? So that commands like those will colorize the whole output according to the language of the file (from extension or magic): cat my-script.py or head -n 15 my-script.lua (HowTos)