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

Support grep color format #64

Closed
baptistemarchand opened this issue Jul 8, 2015 · 5 comments
Closed

Support grep color format #64

baptistemarchand opened this issue Jul 8, 2015 · 5 comments
Assignees

Comments

@baptistemarchand
Copy link

Hi!

I'm having fun playing with rtail but I want to use it to monitor scripts that use grep to colorize their output and it doesn't seem to work well with rtail.
To reproduce, the following command should display 'lol' in red in the terminal but not in the rtail UI.

$ echo lol | grep --color=always lol | rtail --id test_grep

This is the format that grep uses:

$ echo lol | grep --color=always lol | cat -e
^[[01;31m^[[Klol^[[m^[[K$

I'm not sure if this is more of an ansi_up issue, or if there are some GREP_COLORS options I could set to fix it.

Thank you for your help and for building something cool!

@kilianc
Copy link
Owner

kilianc commented Jul 8, 2015

@baptistemarchand thanks for contributing.

ANSI parsing apparently is very hard. I spent quite some time looking for the "right" lib without luck. As you can see the color is parsed ~correctly, it may be a problem with [K. I will google it up but it's ansi_up issue. I am open to suggestions on alternative libs.

8rdw6zhuc19ae4ydvwpcragx65kzg4q-8ierchasaxy

@kilianc
Copy link
Owner

kilianc commented Jul 8, 2015

try this:

$ echo -e "\e[01;31mlol\e[m aaa" | rtail --name test_grep

the problem appears to be grep adding a clearline escape.

ref: http://unix.stackexchange.com/questions/45190/grep-color-adds-ansi-code-esck-this-can-change-displayed-text

@kilianc
Copy link
Owner

kilianc commented Jul 8, 2015

$ GREP_COLORS=ne echo lol aaa | grep --color=always lol | rtail --id test_grep

did we do it? 💃

@baptistemarchand
Copy link
Author

Thanks for your quick answer!
I tried the GREP_COLORS solution yesterday and couldn't get it to work. After some investigation today it appears that BSD grep (the version used on mac) doesn't support the GREP_COLORS variable. I tried it on Linux and it works fine with GNU grep.
This is getting really outside the scope of rtail so you can probably close this issue. I'll let you know if I find an elegant workaround for OSX!
It might be useful to document the GREP_COLORS=ne thing somewhere, like in the README or some FAQ.
Thanks!

@kilianc
Copy link
Owner

kilianc commented Jul 9, 2015

@baptistemarchand thanks for contributing.

@kilianc kilianc closed this as completed Jul 9, 2015
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