Somehow `less` only has 328 GitHub stars! Give it some love ⭐️

github.com/gwsw/less

@adamchainz @pganssle I really appreciate that they're still adding new features, like the recently added `--redraw-on-quit` option which is amazing.

@JakubKuczys @pganssle oh, I saw that but
I don’t see why it is useful… can you fill me in?

Follow

@adamchainz @pganssle (TL;DR at the bottom) by default, less draws to the alternate screen so when you quit it, you no longer see what you've seen right before quitting, you just get back to the terminal as if the command never returned anything.
If you Google for this, you'll find that there's an `-X` option that allows you to set less to draw on the primary screen but this has a couple of drawbacks. Notably, this makes less not capture mouse scroll events which means you can no longer scroll through the file with mouse scroll.
If, instead of `-X`, you use this new `--redraw-on-quit` option, less will continue drawing on the alternate screen, so mouse scroll will work and after quitting less will just redraw what you've last seen before quitting on the primary screen.
I find this useful because after finding what I need using less, I usually want to type some command that's based on what I've seen there and this allows me to still see what I was looking at after quitting less.

TL; DR:
<no options> - doesn't keep output after quitting, mouse scroll works
`-X` - keeps output after quitting, breaks mouse scroll
`--redraw-on-quit` - keeps (technically redraws) output after quitting, mouse scroll works

@JakubKuczys @pganssle Ahhh brilliant. I’ve always stuck with -X. Couldn’t figure out the use of combining with -X … good to know it’s really an alternative fix/workaround.

I’m writing a book section on configuring less right now, I’ll include the new option now. Thanks for the explanation.

Would you like to beta read this section?

@adamchainz sure! I don't know that much about less but it does have a lot of (probably interesting) options so maybe I'll learn something and I'll be sure to give my feedback once I read it. I was just quite happy (even made a backport ppa for ubuntu 22.04) when I ran into the new `--redraw-on-quit` since it's always bothered me so I wanted to share 😄 One other problem I have with less but doesn't really seem solvable yet is with top of less's output getting cut out after quit due to multi-line prompt:
github.com/gwsw/less/issues/84
It's way more specific though so not getting my hopes up.

@adamchainz welp, I was wrong, this was implemented a week ago! Now I can use `LESS_LINES=-2` to put 2 lines of bottom margin in `less` which makes it work better on exit with my 3-line prompt. I'm told the performance may be suboptimal but so far I'm happy with it.

@JakubKuczys hey, I'm ready to send the first beta read version of my book. If you're still interested, what's your preferred email address?

@adamchainz me (at) jacken.men, you can also find it listed on my GitHub profile.

@adamchainz hi, I never received that email so I just want to make sure that it wasn't lost in transit and you just haven't sent it yet.

@JakubKuczys sorry I swear I never got the masto notification... emailed earlier today

Sign in to participate in the conversation
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.