-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
line numbers only when reading file (and tty) #380
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
Comments
I think you mean If so, this has something I've thought about since I made ripgrep. I kind of side with you on this. I think showing line numbers when searching only stdin is a little strange. I'm not quite sure if the right answer is to remove them in that specific case, which I think is why I never bothered to change it. If you do pipe ripgrep into another program, e.g., |
oops yes. But it was a bit tongue-in-cheek, i hope we can come up with something more elegant than such a flag. In fact, it seems we both think it would be sensible to adjust default behavior for this case :) do you see any downsides to introducing this change? |
Errm, yes, on the same page. :-)
I think the key downside is the case analysis and behavioral changes. For example, |
right. agreed.
We could turn this:
into this:
for me the same reasoning applies. stdin is a stream so line numbers are meaningless to me. for files they are meaningful. so when you do both in one run, those ideas still apply IMHO |
I find the idea of having an inconsistent output format in the same set of search results a bit unnerving. I think I'm OK with the other stuff. |
actually me too, I think we can keep |
thank you @BurntSushi , i'm enjoying the new output already when piping things into ripgrep :) |
For copy paste, you can do
or
In this case, stdout is not a tty so ripgrep (even before 4ef4818) does not print line numbers. |
my workflow is that typically i'll run ripgrep manually, potentially a few times while tweaking the pattern to get an narrow but accurate output, and then i just use my mouse to copy the output that is already visible. |
Hello,
first of, ripgrep is slick. thank you very much. I have one letter of the alphabet (
r
) dedicated to just ripgrep. because typingrg
would be too much for me. that's how much i use it. my alias actually invokesrg -j1
so that i get deterministic output (FWIW)anyway, i know how line number printing behavior is determined by whether you're in a tty or not, and then you can still turn it on and off explicitly.
Personally, i find them a bit too annoying when i'm matching against stdin. since stdin is typically a stream, line numbers don't make sense. especially when i then want to copy paste the output to others, things can get confusing. so could we do a mode for
line-numbers-only-when-tty-and-stdin
or something?If i'm the only one asking for this and/or it doesn't seem worth it, I'll learn how to live with it...
so to be clear what I mean is, if you're in a terminal
Thanks again. cheerios!
The text was updated successfully, but these errors were encountered: