Overview
tmux provides extensive mouse support for interacting with windows, panes, and copy mode. When enabled, the mouse can select panes, resize borders, select windows, and interact with scrollbars.Enabling Mouse Support
Basic Configuration
~/.tmux.conf
- Pane selection by clicking
- Pane resizing by dragging borders
- Window selection from status line
- Scrolling in panes and copy mode
- Text selection and copying
- Scrollbar interaction (if enabled)
Terminal Requirements
Fromtty-features.c:75-83, mouse support requires the terminal feature:
Mouse Event Types
Standard Mouse Sequences
Fromtty-keys.c:1173-1183, tmux handles multiple mouse protocols:
- Standard Mode
- SGR Extended Mode
- UTF-8 Mode
Original xterm mouse tracking:Limited to 223x223 terminal size.
Mouse Button Codes
Fromtty-keys.c:1286-1299, tmux tracks:
0: Left button1: Middle button2: Right button64: Wheel up65: Wheel down- Additional bits for Shift, Meta, Ctrl modifiers
Mouse Operations
Pane Selection
Fromserver-client.c:692-900, clicking in a pane:
Handle Click Type
- Single click: Select pane
- Double click: Enter copy mode and select word
- Triple click: Enter copy mode and select line
- Drag: Enter copy mode and select text
Pane Resizing
Dragging pane borders:- Mouse down on border starts drag
- Mouse move adjusts pane size
- Mouse up completes resize
layout.c:646-669, resize updates the layout tree.
Window Selection
Clicking on window names in status line:server-client.c:818-838, range detection identifies which window was clicked.
Scrolling
- Pane Scrolling
- Status Line Scrolling
- Scrollbar Scrolling
Wheel events in pane:Behavior:
- If in copy mode or mouse mode is on in pane: send wheel event to application
- Otherwise: scroll 5 lines or enter copy mode
Copy Mode Mouse Support
Text Selection
Fromwindow-copy.c:5858-5909, mouse drag in copy mode:
Mouse Bindings in Copy Mode
Default bindings fromkey-bindings.c:528-532 and 640-644:
Copy Mode
Mouse Mode Detection
Fromserver-client.c:852-863, tmux tracks whether the running application has enabled mouse support:
mouse_any_flag is set, the application (like vim or less) is handling mouse events, so tmux passes them through.
Advanced Mouse Configuration
Custom Mouse Bindings
~/.tmux.conf
Disable Specific Mouse Actions
Mouse Without Scrolling
Scrollbar Integration
When pane scrollbars are enabled:server-client.c:886-898, mouse events in scrollbar area:
- Clicking to scroll to position
- Dragging slider
- Wheel events in scrollbar area
Troubleshooting
Mouse not working in terminal
Mouse not working in terminal
Verify terminal supports mouse:From
tty-features.c:475-485, modern terminals should include mouse in their default feature set.Mouse events not reaching application
Mouse events not reaching application
Check If application needs mouse events, it should request them via terminal escape sequences.
mouse_any_flag:Drag selection not working
Drag selection not working
From Reset tmux client if drag state is stuck:
tty.c:382-384, ensure drag tracking is initialized:Mouse coordinates off by one
Mouse coordinates off by one
From Standard mode uses 1-based. Coordinate system differences can cause confusion.
tty-keys.c:1264-1267, SGR mode uses 0-based coordinates:Performance Considerations
- Every mouse event requires processing and potential layout updates
- Rapid scrolling generates many events
- Mouse dragging for selection triggers frequent redraws
server-client.c:715-716:
Related Options
mouse- Master mouse enable optionpane-scrollbars- Visual scrollbar displaymode-keys- Affects mouse behavior in copy modeset-clipboard- Integration with mouse selection
Related Commands
send-keys -M- Send mouse event to panedisplay-menu- Show context menu at mouse positioncopy-mode- Enter copy mode with mouse