rainbow
rainbow copied to clipboard
Multiple colors for a filter
Hi,
From reading #64 I suspect that this might not be supported, but... let's give it a try anyway.
I'm trying to tweak the ifconfig output to look more reasonable, and by doing so I want to combine "bold" and a color. Like below. But this doesn't work; only the first one gets used. Is there any way to work around this?
[filters]
underline: ^([^\ ]+)
bold: ^\ *inet\ [0-9.]+
cyan: ^\ *inet\ [0-9.]+
That's because filters are applied one by one, so the second one does not match anymore because ANSI escape codes have been inserted in the buffer. You can try making the second one less strict by removing ^, or try to match the non printable characters with a character range '[\x7f\x80]'
Thanks @nicoulaj! This is what I ended up with:
[filters]
bold: ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})
cyan: ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}|^([^\ ]+))
It looks like this on my machine. As indicated by the screenshot, I have a number of interfaces (because I'm using Docker) which is why coloring the output is rather helpful. Let me know if you want this submitted as a PR, I'll gladly submit it if you are interested in it.
