ack(-grep)有哪些颜色选项可用于输出,日志等的着色?

yll*_*ate 14 bash shell logging ack

哪里可以找到所有颜色组合的列表或可以使用ack(-grep)?我发现通过日志ack-grep可以非常有助于检测错误,警告或各种其他条件,尤其是着色,但是我还没有找到可以使用哪些组合的权威列表等.

tail -f development.log \
| ack-grep --flush --passthru --color --color-match=yellow "^.*warning.*"
Run Code Online (Sandbox Code Playgroud)

我见过的选项,例如标准颜色:red,blue,yellow,green,等.

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

但还有什么?

And*_*ter 24

ack使用Perl的Term::ANSIColor模块,因此您可以查看可用的内容:

perldoc Term::ANSIColor
Run Code Online (Sandbox Code Playgroud)

这是相关的摘录.

   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.
Run Code Online (Sandbox Code Playgroud)

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

我们欢迎您访问ack-users邮件列表

  • 在linux(Ubuntu 11.10)服务器上,我看到`bright_`引起了一个错误:`/usr/share/perl5/App/Ack.pm第1155行的无效属性名称bright_black`-是否应该将其带到此时的邮件列表? (3认同)

Ond*_*ert 8

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

--color
--color-match=on_white
--color-filename=red
--color-lineno=magenta
Run Code Online (Sandbox Code Playgroud)

例如,要在白色控制台背景上获得可读结果.(实际上我之所以开始搜索并发现这个问题和来自@ andy-lester的有用回复).