Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple colors for a filter #113

Open
perlun opened this issue Aug 21, 2019 · 2 comments
Open

Multiple colors for a filter #113

perlun opened this issue Aug 21, 2019 · 2 comments

Comments

@perlun
Copy link

perlun commented Aug 21, 2019

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.]+
@nicoulaj
Copy link
Owner

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]'

@perlun
Copy link
Author

perlun commented Sep 24, 2019

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.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants