4 ms·
One thing I never liked about ripgrep is that it doesn't have a pager. Yes, it can be configured to use the system-wide ones, but it's an extra step (and every
by tredre3 3y ago
One thing I never liked about ripgrep is that it doesn't have a pager. Yes, it can be configured to use the system-wide ones, but it's an extra step (and every time I have to google how to preserve colors) and on Windows you're SOL unless you install gnu utils or something. The author always refused to fix that.
Ugrep not only has a pager built in, but it also allows searching the results which is super nice! And that feature works on all supported platforms!
- burntsushi 3y agoThis is what I do personally: $ cat ~/bin/rgp #!/bin/sh exec rg -p "$@" | less -RFX Should work just fine. For Windows, you can install `bat` to use a pager if you don't otherwise have one. You don't need GNU utils to have a pager.
- anjanb 3y agohi @burntsushi, fan of your tool. like it's speed and defaults. I use windows : didn't understand what you mean by "install `bat`" to use a pager. I use cygwin and WSL for my unix needs. I have more and less in cygwin for use in windows.
- burntsushi 3y agoI referenced bat because I've found that suggesting cygwin sometimes provokes a negative reaction. The GP also mentioned needing to install GNU tooling as if it were a negative. bat is fancy pager written in Rust. It's on GitHub: https://github.com/sharkdp/bat https://github.com/sharkdp/bat
- anjanb 3y agoI'm sure you know but windows command prompt always came with its inbuilt pager -- more. So, you could always do "dir | more" or "rg -p "%*" | more ". (more is good with colors without flags)
- burntsushi 3y agoI didn't! I'm not a Windows user. Colors are half the battle, so that's good. Will it only appear if paging is actually needed? That's what the flags to `less` do in my wrapper script above. They are rather critical for this use case.
- ilyagr 3y agoI don't believe bat is a paper; it's more of a pretty-printer that tends to call less. Two pallets that should work on Windows are https://github.com/walles/moar https://github.com/walles/moar (golang) and https://github.com/markbt/streampager https://github.com/markbt/streampager (Rust). There might also be a newer one that uses rust, I'm unsure.
- ttyprintk 3y agoI'd recommend ov for Windows users. https://github.com/noborus/ov https://github.com/noborus/ov bat on Windows does page, but I believe it's only available on Choco and not winget.
- ilyagr 3y agoGood find, thanks! I'll check if I prefer it to moar. As for bat, according to https://github.com/sharkdp/bat#using-bat-on-windows https://github.com/sharkdp/bat#using-bat-on-windows, the Chocolatey package simply installs `less` alongside `bat`. Seems like a good idea, but I haven't tried it.
- ttyprintk 3y agoAh, thanks for doing the footwork.
- bornfreddy 3y agoInteresting - for me a built-in pager is an antifeature. I don't want to figure out how to leave the utility. Worst of all, pager usually means that sometimes you get more pages and you need to press q to exit, and sometimes not. Annoying. I often type yhe next command right away and the pager means I get stuck, or worse, pager starts doing something in response to my keys (looking at you, `git log`). Then again I'm on Linux and can always pipe to less if I need to. I'm also not the target audience for ugrep because I've never noticed that grep would be slow. :shrug:
- VTimofeenko 3y agoSome terminal emulators (kitty for sure) support "open last command output in pager". Works great with a pager that can understand ANSI colors - less fussing around with variables and flags to preserve colors in the pager
- amethyst 3y agoYou might appreciate setting `PAGER=cat` in your environment. ;) Git obeys that value, and I would hope that most other UNIXy terminal apps do too.
- bornfreddy 3y agoOh, wow, thank you! I must try this.