Skip to content
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

Rich as a drop-in replacement for "more"/"less" #72

Open
daniel-kun opened this issue Oct 21, 2022 · 3 comments
Open

Rich as a drop-in replacement for "more"/"less" #72

daniel-kun opened this issue Oct 21, 2022 · 3 comments

Comments

@daniel-kun
Copy link

This is a feature request, sort of.

I think that rich is awesome, and I intuitively wanted to use rich as a replacement of less, which I usually use to have a quick look at text files from my terminal.

However, plain rich behaves more like cat in that it prints all the stuff to the console and then exits. However - this is of course a personal opinion, but maybe the majority of rich users think the same way - I'd much prefer to have rich use --pager by default.

So my question is: Wouldn't it make sense to have rich use the pager by default when in an interactive terminal, and fall back to plain cat-behaviour when used e.g. in pipes or something?

Sure, I could solve this with an alias. But I really think that maybe this could be a useful default behaviour for the majority.

Thanks for the great work on rich and the other related toolkits! 🚀

@davep
Copy link

davep commented Oct 21, 2022

In case it helps: I use rich the other way around, petty much. I still use less as my pager (I've been using it for enough decades that I can't stop typing it), but I use rich as the LESSOPEN to render things nicely. See this bit of code in my fish config.

@gl-yziquel
Copy link

gl-yziquel commented Oct 10, 2024

Well, I'd like to be able to do | rich --pager - when I need to. Unfortunately, what is fed to stdin (as I do with less or batcat) conflicts with the keystrokes I use to scroll down. less and bat/batcat do not have this problem.

There is a need to have rich behave as less. (In my case, massaging pdf files with mutool to display them as text and then paging it with rich formatting; all that as a one liner.)

@Aaron-Fine
Copy link

I recommend solving this by adding an "integrations" section (or similar) to the main Readme and include the snippet from @davep for fish and the following for bash (adapted directly from what @davep already did):

if hash rich 2>/dev/null;
then
    export LESSOPEN="|rich --force-terminal  %s"
    export LESS="--RAW-CONTROL-CHARS"
fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants