Recently, I upgraded to tmux 2.1 and it broke my ability to scroll panes with the trackpad automatically.

Fortunately, I found the fix after scrolling through this GitHub issue thread: tmux/tmux#145. I found I only needed the following lines to get scrolling working smoothly again:

# Enter copy mode when scrolling over a pane
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M

The other requirement I have is to integrate vim and tmux copy paste buffers with the OS X clipboard. I followed the instructions in this blog post and have been happy ever since: Making the clipboard work between iTerm2, tmux, vim and OS X. You should go do everything the author recommends in that post. It will make your terminal time more pleasant and productive.

The only change I made was to remove the following configuration from my ~/.tmux.conf because it made it slow to open new windows and panes, which is something I do very frequently. I haven’t noticed any missing functionality as a result of removing this line from my config.

set-option -g default-command "reattach-to-user-namespace -l bash"

One caveat to this integration is that it makes it really easy to lose your buffer in vim. For example, you copy a URL in the browser, delete a line in vim, and then paste what you thought was the URL but instead was the clipboard contains the line you deleted. That’s frustrating!

It took about a week for me to form the habit of entering visual mode to paste text instead of first deleting then entering insert mode. In fact, it saves me a keystroke, so for me it is a habit well worth adopting.

Hopefully this post saves someone hours of tinkering with your vim/tmux configs to get things playing nice on OS X. I keep my configs on GitHub so I can keep them in sync across the various computers and servers I use daily. Feel free to browse them if you’re curious and want to see what other goodies are in there ;-)