Using tmux mouse mode on wayland

Tmux mouse mode can be enabled by setting set -g mouse on in your tmux settings file. This is probably at ~/.tmux.conf . You can reload this in tmux to rapidly try different settings using tmux source-file ~/.tmux.conf to load it.

I found in mouse mode copy-paste into the “primary” buffer on wayland (on Fedora 40) wasn’t working as I desired. I wanted to copy into the buffer just by selecting text and paste using middle click.

This worked fine inside pure tmux, and also fine purely outside tmux but crossing over didn’t work. That is: selecting something outside of tmux and then middle clicking inside it just pasted whatever was left over in the tmux buffer; selecting something in tmux and then middling clicking outside (e.g. in firefox) just pasted whatever was left over in the main wayland buffer.

The solution for me was to set:

set -s copy-command 'wl-copy'

bind -n MouseDown2Pane run "tmux set-buffer -b primary_selection \"$(wl-paste -p)\"; tmux paste-buffer -b primary_selection; tmux delete-buffer -b primary_selection"


This was inspired by a blog from someone named Sean which has a slightly more complex version and works using X11.

My investigations lead me to the wl-copy and wl-paste utilities which you might also find interesting / convenient if your workflow involves lots of copy and paste between places.