When viewing a long file in Terminal with less
(or man
, which uses less
internally), I can use two-finger gesture to scroll up and down the file; it's great. But less
on OS X has an annoying problem: When I quit, it resets the screen back to what it looked like before I started less
.
% date
Sun 30 Oct 2016 16:18:23 CET
% man less
% (hmm... where did my output go?)
When I quit I want to see the next prompt appear below the last screenful I was viewing in less
. I can achieve this by using less -X
or setting LESS=-X
, which suppresses the terminal initialization sequences. Unfortunately, -X
also turns off the mouse-scrolling feature. Is there a way to suppress the screen clearing but still be able to scroll with the trackpad?
As I understand it, this would require using a different set of terminfo
settings. I cannot make heads or tails of the whole terminfo
infrastructure. Does anyone have a solution? I'm on El Capitan, in case it makes any difference.
Best Answer
This question is nearly identical to a question asked on SuperUser. Here's a portion of the answer: