Recently I made a discussion on using a pager for log/diff/credit output. This has been implemented using the pager
crate. But there is a severe issue with this implementation: Windows support.
As with pager
and the current implementation, it requires less to be available: which is not present in Windows. You either have to package less
or do something like what git
does; packaging the GNU coreutils.
This could prove really difficult to release and maintain. I think the best approach would be to write a small, asynchronous, message-passing based pager
This would not have the issue of hang ups as that happened with the moins
crate
I am currently working on a prototype
What do you think @pmeunier
I understand pager
does nothing if less
isn’t found, so you’re right that there is no Windows support.
I think you’re totally right that we don’t want to package GNU coreutils, and Rust makes it possible to include a crate, which is what you’re suggestion.
I think this is an ambitious project, and I totally support you. You could try to focus on Windows-only support first, since making a portable pager sounds really hard.
It doesn’t even have to take its input from stdin, but from an arbitrary instance of Read + Seek.
You almost got my point.
First, the crate going to be a library. It will have a function like init
, which would essentially switch to the alternate screen of the terminal and return the transmitter part of a channel. It will also start two asynchronous jobs, one to check if the recipient has data, and second to check for key pressure. The data could be any type that implements std::fmt::Display
The concept may not make sense or be clear right now. This will though, once it reaches a mature state and I have some working examples
Also a kind request to everyone here, if anyone is interested to actively contribute, I really welcome it
Here’s the link to the repo (It’s actually empty as I didn’t pushed to it)
I am not currently hosting it on the Nest because of two reasons
- It’s not mature and I will not publish it crates.io until it’s ready
- The only other option that Cargo has is git
2 Likes
FWIW, I use this as a pager, and it happens to be rust-based:
By default, bat
pipes its own output to a pager (e.g less
) if the output is too large for one screen. If you would rather bat
work like cat
all the time (never page output), you can set --paging=never
as an option, either on the command line or in your configuration file. If you intend to alias cat
to bat
in your shell configuration, you can use alias cat='bat --paging=never'
to preserve the default behavior.