3

On macOS Ventura, on a MacBook Air, with a fresh user account and default settings, in Terminal.app, I can run man less and then use my trackpad to scroll down the manpage -- equivalent to hitting j or down arrow.

In iTerm.app (3.4.18), man less displays the manpage, but "Mouse Reporting" does not become checked in the Session -> Terminal State menu, so scrolling with the trackpad down the page does nothing, and up goes into the terminal scrollback. Running man less | less --mouse activates mouse reporting, and I get the desired behavior (what happens in Terminal.app).

I believe that Terminal.app might be doing some magic to activate mouse capture for less without the additional explicit option. How does this work (i.e. what's different between the two shell instances), and how can I get the same behavior from iTerm.app?

One solution is to add export LESS='--mouse' to my .zshrc, but this doesn't answer my question of why I don't need this in Terminal.app.

NReilingh
  • 5,777

1 Answers1

1

Navigate to Settings > Advanced and then change the option Scroll wheel sends arrow keys when in alternate screen mode to Yes. This worked for me to fix the issue.

screenshot of where the "Scroll wheel sends arrow keys when in alternate screen mode" can be found in iTerm2's settings, with the specific setting circled in red

As mentioned in this answer, when you use man (or even just plain old less), less is opened in an alternate screen. Since less does not enable mouse support by default, this setting works around that by converting your scroll to pressing the up and down arrows on your keyboard.

Source: https://apple.stackexchange.com/questions/440527/scrolling-issue-in-vim-after-switch-to-iterm2

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center. – Community Dec 28 '23 at 22:30