iTerm2 tmux mouse scrolling issue

I was in a Mosh session on a remote server and tried to do scroll using trackpad. Surprisingly instead of getting the scrolled content of the remote shell, it showed buffered content of my system’s shell!

I opened up tmux inside the mosh session thinking may be it would help. Nope the same issue.

Local tmux as well has the same issue. The scoll mode (ctrl B [) in tmux with keyboard navigation worked as expected (in remote as well).

mux mouse scrolling broken
tmux mouse scrolling broken

The fix

Appraently there is a quick fix with iTerm2 in Mac.

  1. Goto iTerm2 > Preferences > Advanced
  2. In Mouse section, set Scroll wheel sends arrow keys when in alternate screen mode to Yes
iTerm advanced preferences
iTerm advanced preferences


Now the content will get scrolled correctly within tmux window pane in scoll mode.

tmux mouse scrolling fixed
tmux mouse scrolling fixed

Although mosh scrolling issue is not fixed (now mosh scroll gives walk through commands history), tmux mouse scrolling fix, indirectly fixed my issue. So, yay! 🎉