Skip to main content

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
This single option enables:
  • 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

From tty-features.c:75-83, mouse support requires the terminal feature:
Most modern terminals support this automatically.

Mouse Event Types

Standard Mouse Sequences

From tty-keys.c:1173-1183, tmux handles multiple mouse protocols:
Original xterm mouse tracking:
Limited to 223x223 terminal size.

Mouse Button Codes

From tty-keys.c:1286-1299, tmux tracks:
Button mapping:
  • 0: Left button
  • 1: Middle button
  • 2: Right button
  • 64: Wheel up
  • 65: Wheel down
  • Additional bits for Shift, Meta, Ctrl modifiers

Mouse Operations

Pane Selection

From server-client.c:692-900, clicking in a pane:
1

Detect Click Location

Determines if click is in pane content, border, or scrollbar.
2

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
3

Update Focus

Update focus and potentially resize window.

Pane Resizing

Dragging pane borders:
When dragging:
  1. Mouse down on border starts drag
  2. Mouse move adjusts pane size
  3. Mouse up completes resize
From layout.c:646-669, resize updates the layout tree.

Window Selection

Clicking on window names in status line:
From server-client.c:818-838, range detection identifies which window was clicked.

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

From window-copy.c:5858-5909, mouse drag in copy mode:
1

Start Drag

Mouse down in pane enters copy mode and starts selection.
2

Update Selection

3

Complete Selection

Mouse Bindings in Copy Mode

Default bindings from key-bindings.c:528-532 and 640-644:
Copy Mode

Mouse Mode Detection

From server-client.c:852-863, tmux tracks whether the running application has enabled mouse support:
When 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:
From server-client.c:886-898, mouse events in scrollbar area:
Scrollbar mouse support includes:
  • Clicking to scroll to position
  • Dragging slider
  • Wheel events in scrollbar area

Troubleshooting

Verify terminal supports mouse:
From tty-features.c:475-485, modern terminals should include mouse in their default feature set.
Check mouse_any_flag:
If application needs mouse events, it should request them via terminal escape sequences.
From tty.c:382-384, ensure drag tracking is initialized:
Reset tmux client if drag state is stuck:
From tty-keys.c:1264-1267, SGR mode uses 0-based coordinates:
Standard mode uses 1-based. Coordinate system differences can cause confusion.

Performance Considerations

Mouse support has minor performance implications:
  • Every mouse event requires processing and potential layout updates
  • Rapid scrolling generates many events
  • Mouse dragging for selection triggers frequent redraws
From server-client.c:715-716:
Enable verbose logging to see mouse event frequency.