There's a way to make `^q` quit `less` and not clear the screen (like `less -X`), while `q` quits `less` and clears the screen (like normal `less`).
1. Do `echo '^q toggle-option -redraw-screen\nq' >> ~/.config/lesskey`
2. Make sure `less` is invoked without `-X` (or with `-+X` if you want to be sure).
This `^q` command is particularly useful for `git log` output and other things where you might need to refer back to them in the next terminal command you do. (In fact, `git` uses `less -FRX` by default, so you'd need to override its config to use `less -FR` instead for the above to work as intended). The `q` command is useful when you don't want to lose what you had on the screen before invoking `less`.
The original version I suggested works too, but by accident. `redraw-on-quit` is the actual option name.
(I'd edit my original message, but it's too late for that)
----
Also, note that if you put `--redraw-on-quit` into your `LESS` config (and not `-X`), and set up `^q` as above, things will still work but with flipped behavior of `q` and `^q`.
If your version of `less` is new enough, I believe that the `--redraw-on-quit` behavior is in every way (slightly) better than the `-X` behavior. In addition to the above, some terminals have special behaviors in alternate screen (like converting mouse wheel to up/down keys), which `--redraw-on-quit` will preserve.
See also https://github.com/jj-vcs/jj/wiki/JJ-Con-2025 for a list of all the talks, their slides, and some additional notes. I think the slides are also linked from youtube, but the website definitely has them.