如何在 Linux 或 Unix 系统上使用 ccat 应用程序为 cat 命令输出或文件着色

[ad_1]

cat 命令(concatenate 的缩写)是 Linux、Apple MacOS X、*BSD(FreeBSD / OpenBSD / NetBSD)、类 Unix 操作系统上最常用的灵活命令之一。 在屏幕上显示文本文件、复制文本文件、合并文本文件、创建新文本文件等非常有用。 如果您使用颜色 cat 命令,请尝试 ccat app。

有关可以为 cat 命令输出着色的 ccat 命令的更多信息

ccat 是着色猫。 它的工作方式类似于 cat 命令,但显示内容时会突出显示语法。 它支持 JavaScript、Java、Ruby、Python、Go、C 和 JSON 编程语言。 在具有强大多核 CPU 和大量 RAM 的现代桌面上,与 cat 相比,ccat 命令的开销最小。

安装

我们可以根据我们的 Linux/Unix 发行版安装 ccat。 让我们开始吧。

在 macOS 上安装 ccat

首先,在 macOS 上安装 Homebrew,然后输入以下 brew 命令:
$ brew install ccat

示例输出:

==> Downloading https://homebrew.bintray.com/bottles/ccat-1.1.0.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring ccat-1.1.0.sierra.bottle.tar.gz
?  /usr/local/Cellar/ccat/1.1.0: 4 files, 3.5MB

Arch Linux 安装 ccat /h3>
输入以下命令:
$ sudo pacaur -S ccat

Linux/Unix用户通用安装方法

您的系统上必须安装了 golang。 输入以下命令
$ go get -u github.com/jingweno/ccat

如何使用 ccat 命令?

语法如下:
$ ccat fileNameHere
$ ccat /etc/passwd
$ ccat file.txt foo.txt bar.txt

以 HTML 格式输出

$ ccat --html file.txt

设置深色背景

$ ccat --bg=dark input.txt

设置浅色背景:
$ ccat --bg=light input.txt

您也可以设置颜色代码:
$ ccat -G String="_darkblue_" -G Plaintext="darkred" input

要查看颜色代码/调色板运行的所有可能值:
$ ccat --palette

示例输出:

Applied color codes:

       String	brown
      Keyword	darkblue
      Comment	lightgrey
         Type	teal
      Literal	teal
  Punctuation	darkred
    Plaintext	darkblue
          Tag	blue
      HTMLTag	lightgreen
 HTMLAttrName	blue
HTMLAttrValue	green
      Decimal	darkblue

Color code is in the format of:

  color       normal color
  *color*     bold color
  _color_     underlined color
  +color+     blinking color

Value of color can be black, blink, blue, bold, brown, darkblue, darkgray, darkgreen, darkred, darkteal, darkyellow, faint, fuchsia, fuscia, green, lightgray, overline, purple, red, reset, standout, teal, turquoise, underline, white, yellow

您可以按如下方式从标准输入/键盘读取输入:
$ ccat

你需要按 [CTRL] + [D] 即按住控制键,然后点击 d 退出 ccat 会话:

您也可以直接从网络上阅读源代码:

$ curl https://raw.githubusercontent.com/nixcraft/pf.conf/master/pf.conf | ccat

示例输出:

有关更多信息,请参阅
ccat项目主页
.

结论

您学习了如何使用 ccat 为 cat 命令输出着色。 有关 cat 命令的更多信息,请参阅以下链接:

  • 备注 命令:如何为 syslog 文件以及 ping、traceroute 等程序的输出着色。
  • bat Linux 命令——用 Rust 编写的 cat 克隆

[ad_2]

Related Posts