TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ccat – syntax highlighting cat

127 pointsby jingwenoabout 10 years ago

20 comments

mavidserabout 10 years ago
There&#x27;s also the &quot;python-pygments&quot; package which provides awesome syntax highlighting. You can alias it to ccat too:<p><pre><code> alias ccat=&#x27;pygmentize -g&#x27;</code></pre>
评论 #9498514 未加载
评论 #9498288 未加载
评论 #9498009 未加载
评论 #9499424 未加载
评论 #9500317 未加载
评论 #9500147 未加载
shurcooLabout 10 years ago
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&#x27;s a pure Go binary, so I can just do this:<p><pre><code> go get -u github.com&#x2F;jingweno&#x2F;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&#x27;m more likely to have it installed than any other tools that are not go-gettable.
评论 #9497933 未加载
alfiedotwtfabout 10 years ago
Not to diminish OP&#x27;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>
评论 #9497761 未加载
评论 #9497375 未加载
评论 #9498308 未加载
tanderson92about 10 years ago
alias ccat=&#x27;supercat&#x27; (<a href="http:&#x2F;&#x2F;supercat.nosredna.net&#x2F;" rel="nofollow">http:&#x2F;&#x2F;supercat.nosredna.net&#x2F;</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&#x27;t google search are doomed to reinvent..
评论 #9498196 未加载
评论 #9498726 未加载
albinoloveratsabout 10 years ago
I&#x27;ve been using source-highlight[1] to achieve the same result.<p>[edit]: alias ccat=&quot;source-highlight --out-format=esc --style-file=&#x2F;usr&#x2F;share&#x2F;source-highlight&#x2F;esc.style --failsafe -i &quot;<p>I&#x27;ll have to see how this compares.<p>[1]: <a href="http:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;src-highlite&#x2F;" rel="nofollow">http:&#x2F;&#x2F;www.gnu.org&#x2F;software&#x2F;src-highlite&#x2F;</a>
codychanabout 10 years ago
Why not use `less` instead of `cat`? Besides it is very easy to use `pygmentize` and `source-highlight` to get syntax highlighting result.
userbinatorabout 10 years ago
Seeing as it also reads multiple files and&#x2F;or standard input, I am reminded of this:<p><a href="http:&#x2F;&#x2F;harmful.cat-v.org&#x2F;cat-v&#x2F;" rel="nofollow">http:&#x2F;&#x2F;harmful.cat-v.org&#x2F;cat-v&#x2F;</a><p>&quot;cat isn&#x27;t for printing files with line numbers, it isn&#x27;t for compressing multiple blank lines, it&#x27;s not for looking at non-printing ASCII characters, it&#x27;s for concatenating files.&quot;<p>Why not make it just a syntax highlighting filter? Or is the &quot;cat&quot; functionality too trivial to be factored out, and thus it has grown to include other things? I suppose it&#x27;s a bit of a philosophical question...
评论 #9498718 未加载
评论 #9499998 未加载
DblPlusUngoodabout 10 years ago
Another solution for machines with vim installed:<p><pre><code> vim -u &#x2F;usr&#x2F;share&#x2F;vim&#x2F;vim73&#x2F;macros&#x2F;less.vim &lt;file&gt; </code></pre> less.vim makes vim behave like less with syntax highlighting.
评论 #9500822 未加载
tomweingartenabout 10 years ago
I&#x27;d just hoped someone would make this last week! Only I was hoping it would be named catfancier:<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;tomweingarten&#x2F;status&#x2F;592751132788838401" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;tomweingarten&#x2F;status&#x2F;592751132788838401</a>
AdmiralAsshatabout 10 years ago
Do people cat sourcecode to read it? For anything larger than a five line shell script, I&#x27;d assume one would open it in vim or emacs.
评论 #9498758 未加载
prakashkabout 10 years ago
I use the highlight package[1] that comes with Debian&#x2F;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:&#x2F;&#x2F;packages.debian.org&#x2F;jessie&#x2F;highlight" rel="nofollow">https:&#x2F;&#x2F;packages.debian.org&#x2F;jessie&#x2F;highlight</a> [2] <a href="https:&#x2F;&#x2F;packages.debian.org&#x2F;jessie&#x2F;most" rel="nofollow">https:&#x2F;&#x2F;packages.debian.org&#x2F;jessie&#x2F;most</a>
beberleiabout 10 years ago
This is unfortunate, there is already a &quot;ccat&quot; command short for &quot;ccrypt cat&quot; installable through &quot;ccrypt&quot; on debian based systems.
ryanarteconaabout 10 years ago
Huge missed opportunity to name this thing `scat`, and claim the poop emoji as a logo.
kiddicoabout 10 years ago
I&#x27;ve always used vimcat. It&#x27;s pretty damn slow, but I don&#x27;t mind.
评论 #9498895 未加载
kernyabout 10 years ago
I&#x27;m using vimcat for this. Available as part of vimpager <a href="https:&#x2F;&#x2F;github.com&#x2F;rkitover&#x2F;vimpager" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rkitover&#x2F;vimpager</a>
kmfrkabout 10 years ago
Big fan of hicat myself: <a href="https:&#x2F;&#x2F;github.com&#x2F;rstacruz&#x2F;hicat" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;rstacruz&#x2F;hicat</a>.
pankajdohareyabout 10 years ago
What i usually have done for years is this :<p>sudo apt-get install python-pygments; alias ccat=&#x27;pygmentize&#x27;<p>then :<p>ccat program.js<p>ccat loader.rb #etc...
xupybdabout 10 years ago
Been using this for a while <a href="http:&#x2F;&#x2F;www.vim.org&#x2F;scripts&#x2F;script.php?script_id=4325" rel="nofollow">http:&#x2F;&#x2F;www.vim.org&#x2F;scripts&#x2F;script.php?script_id=4325</a>
boomlindeabout 10 years ago
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.
ameliusabout 10 years ago
I&#x27;m so glad my brain does the syntax highlighting for me.
评论 #9497587 未加载