Grcat lets you configure commands with colour regexps. Then you just prefix the command with "grc", and it will colorize the output according the rules. It's useful to alias commands this way:
$ alias make="grc make"
colout seems most useful when you are want to highlight arbitrary patterns independent of the command, eg. "tail some.log | colout ...".[1] http://kassiopeia.juls.savba.sk/~garabik/software/grc/README...
Plus, colout have a tons of additional features (256-colors mode, colormaps, etc.).
regexp=^\+(.*$)
colours=bold green
count=more
=======
regexp=^\-(--.+$|[^\-].*$|$)
colours=bold red
count=more
========
regexp=^\>([^\>].*|$)
colours=bold green
count=more
=======
regexp=^\<([^\<].*|$)
colours=bold red
count=more
=======
regexp=^@@ .* @@$
colours=magenta
count=more
I agree that colout works better for ad-hoc stuff.You should consider inverting the way it's invoked, though, to be more like grc, otherwise you can't reliably use colout in an alias (as pointed out elsewhere in this thread).
The website says:
colout -r will give you the lists of available colors,
colormaps, themes and supported programming languages.
But I think that's a typo and should be 'colout -h'.Also, a handy alias list of common use cases would be great.
Alias for common use cases are named "themes" in the list of resources.
% colout -r
usage: colout.py [-h] [-g] [-c] [-l SCALE] [-a] [-t] [-s]
REGEX [COLOR] [STYLE]
colout.py: error: too few argumentsI can see a bunch of ways I'll make use of this. The first one I attempted to work on involved trying to color scale the use% in the output of a "df -h".
Alas it didn't work as I expected it:
$ df -h | colout --scale 0,100 "([0-9]*)%" scale
ValueError: could not convert string to float:
However if I grep out just the /dev/sda line it does what I expected: $ df -h | grep /dev/sda | colout --scale 0,100 "([0-9]*)%" scale
/dev/sda 20G 3.2G 16G 17% /
The 17% is a pretty blue.Tips?
df -h | colout "([0-9]+)%" scaleTo get it working I needed to do:
sudo python3 setup.py install
And /usr/local/bin/colout was created for me (unlike what it mentions in the readme atm).It can be done with things liek $PIPESTATUS, but some sort of wrapper/function to do it would be nice.
https://github.com/nojhan/colout/commit/37934e9266d05e1519ac...
https://github.com/nojhan/colout/commit/64454e42f1cf5a4f8cd4...
Update: 37934e9 still works with python 2.6
When I drag it over to the cinema display it looks fine.
Noone else here in the office can see it, both those with good vision and those who are technically blind. Maybe I have special powers. Or a brain tumor.
EDIT: The tool is great btw :)
<red>* This is a colored line [<red>fail<end>]</end>
(You can use the `--debug` switch of colout to get hints about such problems). colout -a -s Python monokai < code.py # just like pygmentize
colout "^(:*)'(:*)'(:*)$" blue,python,blue < code.py # just the code 'inside quotes', not the rest of the line