News for hackers. Stuff that matters.
Re:Ccat – syntax highlighting cat by a3n on Wednesday May 06, 2015 @09:46AM (#9498514)
Brilliant!

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.

Re:Ccat – syntax highlighting cat by rraval on Wednesday May 06, 2015 @10:45AM (#9498984)
Just a quick tip, you would want to use `less -R` (upper case R) instead. `less -r` allows all raw characters which makes it difficult for less to maintain screen appearance. From the man page:

    -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.
Re:Ccat – syntax highlighting cat by Splognosticus on Wednesday May 06, 2015 @12:22PM (#9499782)
You might also want to take a look at less's input preprocessor, which could be used to automatically colorize source.
Re:Ccat – syntax highlighting cat by woof on Wednesday May 06, 2015 @12:59PM (#9500063)
Install src-hilite and use LESSOPEN:

LESS=' -R '

LESSOPEN='| /usr/local/bin/src-hilite-lesspipe.sh %s'

Re:Ccat – syntax highlighting cat by gh02t on Wednesday May 06, 2015 @10:48AM (#9499017)
You can use vimpager instead of less to get highlighting if you want.
Re:Ccat – syntax highlighting cat by a3n on Wednesday May 06, 2015 @11:45AM (#9499496)
I usta do that, but there were occasional quirks. But then, I have occasional quirks and I'm still allowed out of the house.