tmux mouse selection not copying to clipboard? Bind MouseDragEnd + MouseUp
With set -g mouse on in tmux, dragging to select text enters copy mode but the selection stays trapped inside tmux — it never reaches the system clipboard. The fix is a two-line binding that pipes the selection through xclip:
# ~/.tmux.conf
set -g mouse on
# Auto-copy on mouse drag end
bind -T copy-mode MouseDragEnd1Pane send -X copy-pipe-and-cancel "xclip -selection clipboard"
# Fallback: also copy on simple mouse-up (covers cases where drag is too short)
bind -T copy-mode MouseUp1Pane send -X copy-pipe-and-cancel "xclip -selection clipboard"
You need xclip installed (sudo apt install xclip). Reload with tmux source-file ~/.tmux.conf.
The copy-pipe-and-cancel does three things at once: grabs the selection, pipes it to xclip -selection clipboard, then exits copy mode (which clears the highlight). That's how you know it worked — the highlight disappearing means the text is in your clipboard.
Why two bindings
MouseDragEnd1Pane only fires on a proper drag. If you click-and-release too quickly, tmux enters copy mode but the drag-end event never fires, leaving the highlight stuck. MouseUp1Pane catches those cases.
When it won't work
If a pane is running an application that captures mouse input (vim, htop, some CLI tools like GitHub Copilot), tmux forwards mouse events to that program and the bindings don't fire. Your fallback in those panes is holding Shift while selecting — that bypasses tmux entirely and uses the terminal emulator's native selection, but it crosses pane boundaries so the text may include content from adjacent panes.