Timeline for less --quit-if-one-screen without --no-init
Current License: CC BY-SA 4.0
13 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 24, 2023 at 8:04 | comment | added | Steven Lu |
It may be safe to say that this is a bug in less. If less has opened up some content for me to consume using alternate screen, under no circumstances should it then be allowed to auto-quit without being commanded to do so.
|
|
| Feb 24, 2023 at 8:02 | comment | added | Steven Lu |
There's a strange behavior with --quit-if-one-screen that would be funny if it wasn't so rage-inducing. If it doesn't fit in the screen initially, less starts, for which it naturally uses alternate mode, and then I expand the terminal (which is a common and easy operation with a tmux pane), thus expanding the screen, making it fit in one screen, less just up and quits leaving me holding the bag with alternate screen having "helpfully" cleaned out even whatever portion was visible at the time. This is a rather big flaw in the design of --quit-if-one-screen... (tested in less 551)
|
|
| May 19, 2021 at 21:00 | comment | added | Gilles 'SO- stop being evil' | @Timo You don't need to do anything if you have less ≥530. | |
| May 19, 2021 at 19:54 | comment | added | Timo |
Is your script of interest for those with less <530? Do I need cat if I have less >=530?
|
|
| Sep 27, 2018 at 12:22 | history | edited | Gilles 'SO- stop being evil' | CC BY-SA 4.0 |
the latest version of less no longer has this issue (thanks gib, eigengrau82)
|
| Sep 26, 2018 at 23:28 | comment | added | gib | This is now out of date, less has been fixed. See eigengrau82's answer below. | |
| Jun 9, 2017 at 8:14 | comment | added | Peter Cordes |
@ThiefMaster: less could also (but doesn't) have an optional way to quit where it prints the current contents of the screen after sending the un-init string. So you could have the benefit of the alternate screen not cluttering the scrollback, but still leave the relevant part of the man-page or whatever on the terminal after exiting.
|
|
| Jun 30, 2015 at 17:17 | comment | added | stefan | I really liked this idea, and developed it a bit further (with more features): github.com/stefanheule/smartless | |
| Jan 9, 2014 at 17:57 | comment | added | Gilles 'SO- stop being evil' |
@ThiefMaster Thanks for the feedback. Note that you should put #!/bin/bash in your script since you're using bash-specific construct, as it is your script won't work on systems (such as Ubuntu) where /bin/sh is not bash.
|
|
| Jan 9, 2014 at 17:55 | history | edited | Gilles 'SO- stop being evil' | CC BY-SA 3.0 |
bug fixes (thanks ThiefMaster): read LINES from the terminal database since this code is intended for non-interactive shells; increment n in the loop
|
| Jan 9, 2014 at 9:01 | comment | added | ThiefMaster |
I ended up using a modified version of your first code example: gist.github.com/ThiefMaster/8331024 ($LINES was empty when called as git-pager and I think you forgot incrementing $n)
|
|
| Jan 9, 2014 at 8:06 | comment | added | ThiefMaster | "Less has to decide whether to use the alternate screen when it starts. You can't defer that choice to when it terminates." - although it apparently doesn't do it, but couldn't it simply defer any output (such as terminal initialization commands or actual data) until it has received X lines. If stdin is exhausted while X<TERMINAL_LINES it would simply dump everything on stdout and exit, otherwise it would initialize the alternate screen and do what it's supposed to do | |
| Jan 1, 2014 at 0:00 | history | answered | Gilles 'SO- stop being evil' | CC BY-SA 3.0 |