Where can one find a listing of all color combinations or such available to use with ack(-grep)
? I find that passing logs through ack-grep
can be quite helpful at detecting errors, warnings or various other conditions especially with colorization, however I haven't found an authoritative list of what combos may be used, etc.
tail -f development.log \
| ack-grep --flush --passthru --color --color-match=yellow "^.*warning.*"
I've seen options such as the standard colors: red
, blue
, yellow
, green
, etc.
And I've seen that you can use "white on_green"
But what else?
So grep comes with --color='auto' option. It surrounds the matching string with the colour, thus resulting in enhanced output. Now you know grep can color-highlighting the matched text or words in its output. However, by default, that option is turned off.
ack uses Perl's Term::ANSIColor
module, so you can check what is available to you with:
perldoc Term::ANSIColor
Here's the relevant excerpt.
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.
I'm glad to see you using --passthru
, too.
We'd welcome you on the ack-users mailing list
Another interesting thing to do is to create a ~/.ackrc with default configuration like:
--color
--color-match=on_white
--color-filename=red
--color-lineno=magenta
To get readable results on white console background for instance. (Actually the reason why I started to search and found this question and the helpful reply from @andy-lester).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With