-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
rg --help | less assumes the terminal has 100 columns #442
Comments
ripgrep doesn't do anything explicitly smart with terminal size, so I assume this is a clap thing. |
I could have sworn clap had some setting or knob for this, but I can't find it after a quick skim. |
There's
|
[I hit comment too early] Not using either will just "smart" wrap at whatever width the user terminal width happens to be. |
@kbknapp Oh interesting. Welp. I was clearly wrong about ripgrep not doing anything. With that said, I can't seem to cause clap to do the right thing here. Namely, if If I remove the |
I see. clap does do the right thing unless its output is piped to |
Interesting, my initial thinking is |
I haven't looked at clap's source code, but my best guess is that clap only does autowrapping when it thinks its printing to a tty (which seems reasonable). So if its output is piped to a file or to another program, then it won't auto-wrap because it isn't a tty. It should be possible to discriminate between "redirected to a file" and "piped to other process," but even then, it's not clear that respecting terminal size is the right choice (although it certainly seems like a pragmatic one). Another choice is to just set the max width to |
@kbknapp Ah right, beat me to it! |
Here's where the logic happens |
@kbknapp Oh, I suppose that is actually a different issue than what I was saying above. That's suggesting that |
@BurntSushi |
@BurntSushi I found a solution that seems to work! 🎉
|
Nice hack. I love it.
…On Apr 9, 2017 1:46 PM, "Kevin K." ***@***.***> wrote:
@BurntSushi <https://github.com/BurntSushi> I found a solution that seems
to work! 🎉
term_size can read stdout, and if that fails try *stdin*...if *that*
fails then try stderr...*then* give up. Works in my tests so far.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#442 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAb34oa1sa0OdFtgHVn28d9J-BOP-HB3ks5ruRl9gaJpZM4M4C3P>
.
|
Just did a |
I have this issue running |
No, you are right – it seems that With that done, it works even when stdout is a pipe, as in However, the Oh, and it would be nice with a right margin of a few spaces (2, say) for readability. I suppose that would go into |
If we pipe rg's output to something, it assumes the terminal has 100 columns.
For example rg --help, which has output that is long and begs for pagination.
To reproduce: Install rg. Adjust terminal to a width of for example 90 columns. Use
rg --help | less
(with no shell aliases or anything in between).(Sorry! rg --help is now fixed, so the bug report now had its schedule unblocked)
The text was updated successfully, but these errors were encountered: