Add the --colormap option to build adhoc colormaps

Use the given list of comma-separated colors as a colormap (cycle the colors at each match).
Support of 256 colors mode colormaps.
This commit is contained in:
nojhan 2013-03-05 21:53:38 +01:00
commit c891bda94a
2 changed files with 55 additions and 20 deletions

View file

@ -28,10 +28,13 @@ rapid_blink, reverse, conceal or random.
`Random` will color each matching pattern with a random color among the 255
available in the ANSI table. `random` will do the same in 8 colors mode.
`rainbow` will cycle over a 8 colors rainbow at each matching pattern.
When not specified, a *COLOR* defaults to _red_ and a *STYLE* defaults to _bold_.
`colout` is released under the GNU Public License v3.
## OPTIONS
* `-h`, `--help`:
@ -43,14 +46,17 @@ When not specified, a *COLOR* defaults to _red_ and a *STYLE* defaults to _bold_
* `-g`, `--groups`:
For color maps (like "rainbow"), iterate over matching groups in the pattern instead of over patterns.
* `-c`, `--colormap`:
Use the given list of comma-separated colors as a colormap (cycle the colors at each match).
## REGULAR EXPRESSIONS
A regular expression (or _regex_) is a pattern that describes a set of strings
that matches it.
that matches it.
`colout` understands regex as specifed in the _re_ python module. Given that
`colout` is generally called by the command line, you may have to escape
`colout` is generally called by the command line, you may have to escape
special characters that would be recognize by your shell.
@ -87,6 +93,9 @@ special characters that would be recognize by your shell.
`make 2>&1 | colout :\([0-9]+\):[0-9]* yellow normal | colout error | colout warning magenta | colout pragma green normal | colout /\(\\w+\)*\.\(h\|cpp\) cyan normal`
* Color each word in the head of auth.log with a rainbow color map, starting a new colormap at each new line (the
begining of the command is just bash magic to repeat the string "(\w+
begining of the command is just bash magic to repeat the string "(\\w+)\\W+":
`L=$(seq 10) ; P=${L//??/(\\w+)\\W+} ; head /var/log/auth.log | ./colout.py -g "^${P}(.*)$" rainbow`
* Color each line of a file with a different color among a 256 color gradient from cyan to green:
`head /var/log/auth.log | ./colout.py -c "^.*$" 39,38,37,36,35,34`