m4b/bingrep

How to correctly page bingrep output with color?

mathomp4 opened this issue · 4 comments

I just recently discovered bingrep and think it's quite cool. But, in my haste, I decided to try and bingrep ~/.cargo/bin/rg and found it spit out 35000 lines of very nice colorful output. So then tried bingrep ~/.cargo/bin/rg | less and...aww, no color.

But bingrep -h tells me about the --color option and, yay, color...but also a lot of ^O characters everywhere.

So, I'm just wondering: is there a way to page bingrep output and make it look like the non-paged output?

m4b commented

Hi! Yea so less has an option like —color (or something like that don’t recall right now); This should force interpretation of ANSI escape codes (which I assume is what you’re seeing if you’re seeing ^ in the pager)

Let me know if that works for you!

m4b commented

I believe there is a bug I’ve seen paging bingrep output on MacOS (I think), where some parts are uncolored. I believe this was due to the pretty column library turning off color or something, but can’t remember.

That can also be worked around by outputting and forcing color into a file then paging that, iirc

Reverse engineering bat using ps -ef, I came up with this solution:

bingrep file_name --color | less --RAW-CONTROL-CHARS --quit-if-one-screen

I used it and the output was colourful

m4b commented

closing this, the answer should be:

bingrep <file> --color | less -r

let me know if you have issues with this; also closing less should now no longer result in panic, thanks to @koutheir recent patch