15

在哪里可以找到所有颜色组合的列表或可用的颜色组合ack(-grep)?我发现传递日志ack-grep对于检测错误、警告或各种其他情况非常有帮助,尤其是在着色方面,但是我还没有找到可以使用哪些组合等的权威列表。

tail -f development.log \
| ack-grep --flush --passthru --color --color-match=yellow "^.*warning.*"

我见过诸如标准颜色之类的选项:red, blue, yellow,green等。

我已经看到你可以使用"white on_green"

但还有什么?

4

2 回答 2

25

ack 使用 Perl 的Term::ANSIColor模块,因此您可以通过以下方式检查可用的内容:

perldoc Term::ANSIColor

这是相关的摘录。

   The recognized normal foreground color attributes (colors 0 to 7) are:

     black  red  green  yellow  blue  magenta  cyan  white

   The corresponding bright foreground color attributes (colors 8 to 15)
   are:

     bright_black  bright_red      bright_green  bright_yellow
     bright_blue   bright_magenta  bright_cyan   bright_white

   The recognized normal background color attributes (colors 0 to 7) are:

     on_black  on_red      on_green  on_yellow
     on_blue   on_magenta  on_cyan   on_white

   The recognized bright background color attributes (colors 8 to 15) are:

     on_bright_black  on_bright_red      on_bright_green  on_bright_yellow
     on_bright_blue   on_bright_magenta  on_bright_cyan   on_bright_white

   For any of the above listed attributes, case is not significant.

我也很高兴看到您使用--passthru.

我们欢迎您加入ack-users 邮件列表

于 2012-03-08T23:03:55.280 回答
9

另一件有趣的事情是使用默认配置创建一个 ~/.ackrc,例如:

--color
--color-match=on_white
--color-filename=red
--color-lineno=magenta

例如,在白色控制台背景上获得可读的结果。(实际上是我开始搜索并找到这个问题的原因以及@andy-lester 的有用回复)。

于 2016-02-17T13:54:52.010 回答