Use the mouse
Mouse on, right pane active, window logs current, and a drag has copied text.
set -g mouse on at the prompt turns mouse support on. Nothing visibly changes — but four things start working:
- click a pane
- make it active
- click a window name in the status line
- switch to it
- drag over text and release
- copy it into a buffer
- drag a border
- resize
mouse is an option: a named setting held on the server, a session or a window, changed with set-option (set for short). -g sets it globally, for every session.
Press C-b :, type set -g mouse on, Enter.
Nothing on screen changes.
Click the right pane, the one showing right pane.
Its border highlights — it is now active.
Click logs in the status line.
Window logs is current.
Drag across a word in the pane and release.
The text is now in a buffer.
How mouse bindings work
With the mouse on, mouse events are key bindings like any other: a click runs select-pane or select-window, a border drag runs resize-pane. A right click opens a menu with each command’s key shown beside it.
Here is what just happened.
The click ran select-pane with that pane as target, the same command C-b Right runs. The status line click ran select-window. The drag selected in copy mode and the release copied, making an automatic buffer that C-b ] would paste.
- Enable mouse support for every session:set -g mouse on
- Left click a pane to activate it; drag a border to resize; drag over text to copy:bind MouseDown1Pane
- Click a window name in the status line to switch to it; right click opens a menu:bind MouseDown1Status
Go further
set -gu mouseunsets the option, back to off.- Hold Shift while dragging to let the terminal select text itself, for copying into another application.
- 1No mouse events reaching tmux?
C-b Rightfor the pane,C-b 2for the window, andC-b [C-SpaceM-wfor the buffer. - 2Turn it on first:
C-b :thenset -g mouse on. Nothing visibly changes. - 3Click the right pane; click
logsin the status line; drag across a word and release.
This is a live terminal. Typing goes to the machine, including Tab. Press Shift and Tab together to move focus back out to the page.
A real terminal, in this tab
Alpine Linux and tmux 3.4 on an x86 emulator. Nothing to install, and no server behind it.
about 15 MB, once
Done when
not started- The mouse option is on— not done yet
- The right pane of window 0 (index 1) is active— not done yet
- Window logs (index 2) is the current window of session learn— not done yet
- A drag copied text into an automatically named buffer— not done yet