TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ccat – syntax highlighting cat

127 点作者 jingweno大约 10 年前

20 条评论

mavidser大约 10 年前
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 未加载
shurcooL大约 10 年前
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 未加载
alfiedotwtf大约 10 年前
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 未加载
tanderson92大约 10 年前
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 未加载
albinoloverats大约 10 年前
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>
codychan大约 10 年前
Why not use `less` instead of `cat`? Besides it is very easy to use `pygmentize` and `source-highlight` to get syntax highlighting result.
userbinator大约 10 年前
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 未加载
DblPlusUngood大约 10 年前
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 未加载
tomweingarten大约 10 年前
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>
AdmiralAsshat大约 10 年前
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 未加载
prakashk大约 10 年前
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>
beberlei大约 10 年前
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.
ryanartecona大约 10 年前
Huge missed opportunity to name this thing `scat`, and claim the poop emoji as a logo.
kiddico大约 10 年前
I&#x27;ve always used vimcat. It&#x27;s pretty damn slow, but I don&#x27;t mind.
评论 #9498895 未加载
kerny大约 10 年前
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>
kmfrk大约 10 年前
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>.
pankajdoharey大约 10 年前
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...
xupybd大约 10 年前
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>
boomlinde大约 10 年前
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.
amelius大约 10 年前
I&#x27;m so glad my brain does the syntax highlighting for me.
评论 #9497587 未加载