Enable mouse scrolling with tmux 2.1 on Mac

tl;dr

I finally found the solution to automatically enable and disable scrolling on Mac after the tmux upgrade. Thanks again to ArchLinux Wiki.

Add those three lines to your .tmux.conf:

set -g mouse on
bind-key -T root WheelUpPane   if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"

Understand how it works

One thing I found missing on a lot of tech blogs is most of them have only the solution but not why it’s the case. I think we should change this so that everyone can make changes/improvements to meet their needs.

The main thing here is a bind-key command, so let’s check the manual first.

Official manual page on OpenBSD

To understand the command: