alias ccat='pygmentize -g' alias ccat='pygmentize -g'While I was reading the ccat page I was wishing it was a colorized less, rather than a colorized cat.
Then I thought to read the man page for less, because sometimes what you want is already there. And it does handle color, but only if they're escaped colors. Oh well.
Then I saw your comment, tried pygmentize on a python script, and there's some nice colored code, that scrolled off the terminal.
Then I piped that into less, just to be grumpy. Yep, it's all white ... but wait, what are all those escape characters?
...
pygmentize -g myScript.py |less -r
The colors! The colors! And in less, no less.
-R or --RAW-CONTROL-CHARS
Like -r, but only ANSI "color" escape sequences are output in "raw"
form. Unlike -r, the screen appearance is maintained correctly in most
cases.LESS=' -R '
LESSOPEN='| /usr/local/bin/src-hilite-lesspipe.sh %s'
True, it takes some time to highlight some files - for example 5k loc long Racket files or very long XML/HTML files - but it supports all the languages I use (or used or may use in the future), while this tool supports only one of the languages I use on a daily basis.
I read http://pygments.org/docs/styles and other sites but I didn't find how I can change the default colors. Do I have to edit (clone) pygments or is there a config file?
For what it's worth, here's[1] the file which describes the colors used in the source. List of colors[2].
[1] https://bitbucket.org/birkenfeld/pygments-main/src/a287342ee...
[2] https://bitbucket.org/birkenfeld/pygments-main/src/a287342ee...