News for hackers. Stuff that matters.
Re:Ccat – syntax highlighting cat by mavidser on Wednesday May 06, 2015 @04:11AM (#9497187)
There's also the "python-pygments" package which provides awesome syntax highlighting. You can alias it to ccat too:

    alias ccat='pygmentize -g'
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.
Re:Ccat – syntax highlighting cat by klibertp on Wednesday May 06, 2015 @09:08AM (#9498288)
Especially if you need something more than "JavaScript, Java, Ruby, Python, Go, and C" - pygments has a list of supported languages a tiny bit longer than that: http://pygments.org/languages/

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.

Re:Ccat – syntax highlighting cat by IgnotisAnon on Wednesday May 06, 2015 @08:08AM (#9498009)
I do the same. It's funny to see a program with the same name as my alias doing the same thing.
Re:Ccat – syntax highlighting cat by gvalkov on Wednesday May 06, 2015 @11:33AM (#9499424)
I have a small wrapper around `pygmentize -g` in my dotfiles that optionally overwrites the lexer based on the mime-type, as determined by `file`:

https://github.com/gvalkov/dotfiles/blob/master/bin/cats

Re:Ccat – syntax highlighting cat by meandave on Wednesday May 06, 2015 @01:31PM (#9500317)
I got a tad further and detect if the file is markdown, if so i will display in lynx https://github.com/meandavejustice/dotfiles/blob/master/bin/...
Re:Ccat – syntax highlighting cat by progman on Wednesday May 06, 2015 @01:11PM (#9500147)
Yes, brilliant!

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?

Re:Ccat – syntax highlighting cat by mavidser on Wednesday May 06, 2015 @07:37PM (#9502460)
Pretty sure there's no config file, as of now.

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...

Re:Ccat – syntax highlighting cat by progman on Thursday May 07, 2015 @12:56PM (#9506499)
Thanks!