nix icon indicating copy to clipboard operation
nix copied to clipboard

Redirect some Nix commands output to a pager

Open thufschmitt opened this issue 4 years ago • 9 comments

Make nix search, nix flake show and nix flake metadata pipe their output into a pager to make their result easier to visualise.

Fix #4548

thufschmitt avatar Jul 02 '21 08:07 thufschmitt

So the reason I didn't enable paging yet is that it can interact badly with the progress indicator. Maybe what we should do is show the progress indicator until the first output is written, then disable the progress indicator and start the pager.

edolstra avatar Jul 02 '21 09:07 edolstra

So the reason I didn't enable paging yet is that it can interact badly with the progress indicator. Maybe what we should do is show the progress indicator until the first output is written, then disable the progress indicator and start the pager.

I’ve actually disabled the progress indicator altogether when using the pager (here). But waiting for the first output might be nicer (I’ve no idea how to do that though :) ).

thufschmitt avatar Jul 02 '21 09:07 thufschmitt

Ideally we would use logger->writeToStdout / logger->cout everywhere (instead of std::cout), and then the progress bar logger can disable itself and start the pager the first time writeToStdout is called.

edolstra avatar Jul 02 '21 10:07 edolstra

@edolstra I’ve rewritten the proxy mechanism in 8ad1ed5fb66b9443997aac761c1baf6771b30160 to wrap a logger rather than being its own different thing. That way we can nicely intercept writeToStdout to start the pager as needed and tell the underlying pager not to dump arbitrary stuff on stdeer anymore

thufschmitt avatar Jul 07 '21 08:07 thufschmitt

Does less -R support the progress bar?

SuperSandro2000 avatar Dec 18 '21 08:12 SuperSandro2000

Does less -R support the progress bar?

-R wouldn’t. -r might, but it’s a bit hacky (and explicitly not recommended), so I’d rather not rely on that

thufschmitt avatar Dec 22 '21 11:12 thufschmitt

@edolstra friendly ping :)

thufschmitt avatar Jul 03 '23 19:07 thufschmitt

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2023-08-04-nix-team-meeting-minutes-77/31487/1

nixos-discourse avatar Aug 09 '23 05:08 nixos-discourse

Marking it as draft since it has a bunch of conflicts. Anybody want to pick this up?

edolstra avatar Oct 16 '24 19:10 edolstra