set -g mouse on
# Bigger scrollback buffer (default 2000 lines is tiny).
set -g history-limit 100000
# Make the mouse wheel scroll the pane's scrollback even in apps that
# don't use the alternate screen — tmux enters copy-mode on first scroll
# and exits when you reach the bottom.
bind -n WheelUpPane if -F '#{?pane_in_mode,1,#{alternate_on}}' 'send-keys -M' 'copy-mode -e ; send-keys -M'
bind -n WheelDownPane send-keys -M
# Quicker scroll in copy-mode (3 lines per wheel tick instead of 5).
bind -T copy-mode-vi WheelUpPane send -X -N 3 scroll-up
bind -T copy-mode-vi WheelDownPane send -X -N 3 scroll-down
# Keyboard scroll: prefix-[ to enter copy-mode, then PgUp / PgDn / arrows.
# Also bind PgUp directly (no prefix) to drop into copy-mode at the top.
bind -n PageUp if -F '#{alternate_on}' 'send-keys PageUp' 'copy-mode -eu'