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
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 the file which describes the colors used in the source. List of colors.
Honestly, the biggest advantage for me over all other proposed alternatives is that it's a pure Go binary, so I can just do this:
go get -u github.com/jingweno/ccat
I use Go as my primary development language, so I'm more likely to have it installed than any other tools that are not go-gettable.
cat file_name | vi -
A couple things I like about "view":
1. No warning screen when using "view file.c" if you or someone else happens to have the same file open for editing.
2. No "unsaved changes" prompt when quitting "view -" (or in other words, no need to force-quit with :q!)
Edit: Also worth noting is that "view file.c" vs "cat file.c |view -" gives vim a better chance of getting the syntax highlighting right since it knows the file extension.
grep ... files | sed ... | awk ... | vim -
My dad and I wrote virtually this same tool 8 or 10 years ago. The program uses arbitrary regular expressions to match and colorize any file you desire to write a set of rules for. And it ships with some common rules too. This was before pygmentize was very popular (or around at all).
Those who don't google search are doomed to reinvent..
Not to be critical - but you are also forcing people to reinvent by having a custom-rule parser, rather than wrapping an existing lexer library.
the duckduckgo team agrees ;)
: alias ccat="source-highlight --out-format=esc --style-file=/usr/share/source-highlight/esc.style --failsafe -i "
I'll have to see how this compares.
"cat isn't for printing files with line numbers, it isn't for compressing multiple blank lines, it's not for looking at non-printing ASCII characters, it's for concatenating files."
Why not make it just a syntax highlighting filter? Or is the "cat" functionality too trivial to be factored out, and thus it has grown to include other things? I suppose it's a bit of a philosophical question...
vim -u /usr/share/vim/vim73/macros/less.vim <file>
after finding it on a search for a colorized pager
highlight -O ansi file.ext | less -R
highlight -O xterm256 file.ext | less -R
An alternative to `less -R` is the `most` pager .
sudo apt-get install python-pygments;
ccat loader.rb #etc...
Brains do a lot of things, but there is a limit somewhere or at the very least a trade off of speed. Simple things like syntax highlighting can help you find what you are looking for faster.