There's also the "python-pygments" package which provides awesome syntax highlighting. You can alias it to ccat too:<p><pre><code> alias ccat='pygmentize -g'</code></pre>
This is pretty cool, and nice demo gif. Thanks for making it!<p>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:<p><pre><code> go get -u github.com/jingweno/ccat
</code></pre>
On any of my machines. One predictable command will fetch the source, all dependencies and build it without any configuration.<p>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.
Not to diminish OP's project, but I pipe most things to vim to get all my standard highlighting goodness:<p><pre><code> cat file_name | vi -</code></pre>
alias ccat='supercat' (<a href="http://supercat.nosredna.net/" rel="nofollow">http://supercat.nosredna.net/</a>)<p>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).<p>Those who don't google search are doomed to reinvent..
I've been using source-highlight[1] to achieve the same result.<p>[edit]: alias ccat="source-highlight --out-format=esc --style-file=/usr/share/source-highlight/esc.style --failsafe -i "<p>I'll have to see how this compares.<p>[1]: <a href="http://www.gnu.org/software/src-highlite/" rel="nofollow">http://www.gnu.org/software/src-highlite/</a>
Seeing as it also reads multiple files and/or standard input, I am reminded of this:<p><a href="http://harmful.cat-v.org/cat-v/" rel="nofollow">http://harmful.cat-v.org/cat-v/</a><p>"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."<p>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...
Another solution for machines with vim installed:<p><pre><code> vim -u /usr/share/vim/vim73/macros/less.vim <file>
</code></pre>
less.vim makes vim behave like less with syntax highlighting.
I'd just hoped someone would make this last week! Only I was hoping it would be named catfancier:<p><a href="https://twitter.com/tomweingarten/status/592751132788838401" rel="nofollow">https://twitter.com/tomweingarten/status/592751132788838401</a>
I use the highlight package[1] that comes with Debian/Ubuntu. With that:<p><pre><code> highlight -O ansi file.ext | less -R
highlight -O xterm256 file.ext | less -R
</code></pre>
highlight can also convert the input to other formats: HTML, XHTML, RTF, LaTeX, TeX, BBCode or SVG.<p>An alternative to `less -R` is the `most` pager [2].<p>[1] <a href="https://packages.debian.org/jessie/highlight" rel="nofollow">https://packages.debian.org/jessie/highlight</a>
[2] <a href="https://packages.debian.org/jessie/most" rel="nofollow">https://packages.debian.org/jessie/most</a>
This is unfortunate, there is already a "ccat" command short for "ccrypt cat" installable through "ccrypt" on debian based systems.
I'm using vimcat for this. Available as part of vimpager
<a href="https://github.com/rkitover/vimpager" rel="nofollow">https://github.com/rkitover/vimpager</a>
Big fan of hicat myself: <a href="https://github.com/rstacruz/hicat" rel="nofollow">https://github.com/rstacruz/hicat</a>.
What i usually have done for years is this :<p>sudo apt-get install python-pygments;
alias ccat='pygmentize'<p>then :<p>ccat program.js<p>ccat loader.rb #etc...
Been using this for a while <a href="http://www.vim.org/scripts/script.php?script_id=4325" rel="nofollow">http://www.vim.org/scripts/script.php?script_id=4325</a>
A syntax highlighting pager might be more useful to me. cat is a tool that I only use for plumbing, and I rarely want coloring control codes anywhere but stdout.