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
pygmentize
will output a colorized source code file. It has support for many languages. It determines how to color it based on the file extension or the value you provide with the-l
option. To getpygmentize
install thepython-pygments
package.Doesn't look like it's been updated in a while, but what about supercat?