8

I used to be able to scroll using the trackpad through git diff or man pages which both use less when the output doesn't fit on screen. Today I restarted my computer and that behaviour is gone and I can no longer scroll down and if I scroll up it scrolls the terminal scrollbar showing previous commands. However in vim scrolling still works as expected.

The first thing I checked is the "Scroll alternate screen" Terminal setting and it is checked as expected. I also tried with iTerm2 and have the same issue even with the "Scroll wheel sends arrow keys when in alternate screen mode" setting enabled.

My default shell is zsh so I tried with bash and then sh. Both have the same behaviour and I can't scroll through the output.

Because scrolling still works with some commands like vim it seems like the issue might be that less is no longer recognized as an "alternate screen" but I have no idea why. Updating to the latest less version available on brew did not help.

4
  • Same issue here. I have checked everything, it just doesn't work anymore. Commented Jul 30, 2018 at 22:40
  • Almost certain this is the issue: github.com/robbyrussell/oh-my-zsh/pull/6611
    – Chris911
    Commented Jul 31, 2018 at 2:05
  • I was using zprezto and had to change the less settings according to this line: github.com/sorin-ionescu/prezto/blob/…
    – landonepps
    Commented Jan 6, 2020 at 4:13
  • 1
    I know this is old and OP explicitly tried this, but as of February, 2020, i have to toggle "Scroll alternate screen" every time I restart my computer. Terminal -> Preferences -> "Profiles" Tab -> "Keyboard" tab -> toggle off/on "Scroll alternate screen". For anyone encountering this currently. Commented Feb 23, 2020 at 19:38

1 Answer 1

8

it is weird, I had the exact issue this morning with iterm2.

I ended up adding the following to my ~/.zshrc:

export LESS=-R

Important: you might want to take a look at the flags you are using before running this command and understanding what each of them do.

Sources I looked at to arrive to this conclusion:

  1. https://askubuntu.com/questions/803486/can-i-scroll-to-new-lines-using-mouse-wheel-inside-git-diff
  2. https://superuser.com/questions/455212/how-to-make-mouse-wheel-scroll-the-less-pager-using-bash-and-gnome-terminal

Let me know if this helped.

7
  • 1
    echo $LESS returns -FRX at the moment for me. Looks like the -X might be the issue.
    – Chris911
    Commented Jul 31, 2018 at 2:04
  • I tried removing X as well, didn't fix it for me. I also had the same flags enabled. Commented Jul 31, 2018 at 17:49
  • 4
    Adding export LESS=-FR to my .zshrc fixed it for me. In iTerm do you have the "Scroll wheel sends arrow keys when in alternate screen mode" setting set to Yes?
    – Chris911
    Commented Jul 31, 2018 at 18:25
  • 1
    That is correct. "Scroll wheel sends arrow keys when in alternate screen mode" is on. Commented Aug 3, 2018 at 20:17
  • 1
    Thanks Crhis911, that was the setting causing problems in my zsh Commented Sep 2, 2019 at 11:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .