Enable and Use tmux Mouse Mode – Quick Guide
In this article
Yes—you can enable tmux mouse mode by adding set -g mouse on to your .tmux.conf or by typing the command Ctrl+b : set -g mouse on at runtime. Once active, you can click to select panes, scroll, resize windows, and copy text without leaving the keyboard.
What You'll Need
- A working installation of tmux (version 2.1 or newer supports full mouse support).
- A terminal emulator that forwards mouse events (most modern terminals such as iTerm2, GNOME Terminal, Alacritty, and Windows Terminal do this by default).
Step-by-Step
- Open your tmux configuration file. In most setups the file lives at
~/.tmux.conf. If it does not exist, create it withtouch ~/.tmux.conf. - Add the mouse option. Append the line
set -g mouse onto the file. This tells tmux to enable mouse handling for all supported actions. - Reload the configuration. Inside an active tmux session press the tmux prefix (by default
Ctrl+b) then type:to open the command prompt and entersource-file ~/.tmux.conf. Alternatively, you can restart tmux by exiting all sessions (exitorCtrl+d) and starting a new one withtmux. - Test pane selection. Click inside any pane. The pane should gain a highlighted border, indicating that tmux has captured the mouse click.
- Resize panes with the mouse. Move the cursor to a pane border. When the cursor changes to a resize icon, click and drag to adjust the pane size. Release the mouse button to finalize the new dimensions.
- Scroll inside a pane. Use the mouse wheel or trackpad scrolling gesture. If the pane is in copy‑mode, scrolling will move through the buffer; otherwise it will scroll the application running inside the pane (e.g., less, less, or a pager).
- Enter copy‑mode with a click. Right‑click (or left‑click while holding
Shiftin some terminals) to place the cursor at a specific line. Then use the mouse to drag and select text. PressEnterto copy the selection to tmux’s buffer. - Paste the copied text. Return to any pane and press the tmux prefix followed by
]. The text you selected with the mouse will be inserted at the cursor location. - Toggle mouse mode on the fly. If you need to disable mouse support temporarily, press
Ctrl+b :and typeset -g mouse off. Re‑enable it later with the same command, usingoninstead ofoff. - Persist the setting across machines. If you work on multiple hosts, copy your
.tmux.conffile to each machine (using scp, rsync, or a dot‑files manager) so the mouse option is always present.
Common Mistakes
- Forgetting to reload the config. Adding
set -g mouse onwithout reloading or restarting tmux leaves the old configuration active, so mouse actions appear ignored. - Using an outdated tmux version. Versions prior to 2.1 lack the unified
mouseoption and require separate flags (mode-mouse,mouse-select-pane, etc.). Upgrade tmux if the singlemouse online has no effect. - Terminal not forwarding mouse events. Some terminal profiles disable mouse reporting by default. Verify that your terminal’s settings allow mouse reporting (often labelled “Enable mouse reporting” or “Allow mouse events”).
- Conflicting key bindings. Custom key‑bindings that also use the mouse (e.g., plugins that map
MouseDown1Pane) can interfere with tmux’s default behavior. Review anybind-key -n Mouse*lines in your config. - Expecting copy‑mode to start automatically. Clicking alone does not enter copy‑mode unless you hold
Shift(or configureset -g mouse-select-pane onetc.). Remember to press the prefix then[:if you need full copy‑mode features.
Tips
- Combine mouse mode with vim‑style navigation. Keep
set -g mode-keys viin your config so that once you’re in copy‑mode you can still useh j k lkeys alongside the mouse. - Use
set -g mouse onwithsetw -g mode-mouse onfor older tmux. If you must support tmux 1.9, add both lines to cover legacy behaviour. - Adjust scroll speed. Some terminals let you set scroll‑speed or “mouse wheel acceleration”. Tuning this can make scrolling through long logs smoother.
- Copy directly to system clipboard. Install the
reattach-to-user-namespaceutility on macOS or usexclip/xselon Linux, then bindbind-key -T copy-mode-vi y run "tmux save-buffer - | xclip -i -selection clipboard"to copy mouse selections straight to the OS clipboard. - Keep a backup of your config. Before making major changes, copy
~/.tmux.confto~/.tmux.conf.backup. This makes it easy to revert if mouse mode breaks other customizations.
Troubleshooting
If mouse actions do not work as described, follow these steps in order:
- Restart tmux. Exit all sessions and start a fresh one. This clears any stale configuration that might linger after a reload.
- Verify tmux version. Run
tmux -V. Versions 2.1+ support the singlemouse onflag. If you see an older version, update via your package manager (e.g.,brew install tmuxon macOS orsudo apt install tmuxon Debian/Ubuntu). - Check terminal mouse reporting. Inside tmux, press
Ctrl+b :and typeshow-options -g mouse. It should displaymouse on. Then, in a normal shell (outside tmux), runcatand scroll or click; you should see escape sequences like^[[M. If not, enable mouse reporting in your terminal preferences. - Look for conflicting plugins. If you use a tmux plugin manager (TPM), temporarily disable plugins by commenting out the
run -b '~/.tmux/plugins/...'lines, reload the config, and test again. - Inspect custom key bindings. Search your
.tmux.conffor anybind-key -n Mouselines. Comment them out, reload, and see if default mouse behaviour returns. - Test with a minimal config. Start tmux with
tmux -f /dev/null, then manually enable mouse withCtrl+b : set -g mouse on. If it works, the problem lies in your regular config file. - Update the terminal emulator. Older terminal builds may have bugs that prevent proper mouse event forwarding. Upgrade to the latest stable release.
- Check for OS‑level mouse restrictions. Some remote sessions (e.g., SSH with
-X) may block mouse reporting. Try a local session to isolate the issue.
If none of the above resolves the problem, consider posting the minimal config and terminal details on a tmux‑focused forum or the official tmux GitHub issues page.
Frequently Asked Questions
Do I need to restart tmux after enabling mouse mode?
No. You can reload the configuration with Ctrl+b : source-file ~/.tmux.conf or enable it on the fly using Ctrl+b : set -g mouse on. Restarting is only necessary if a reload does not apply.
Can I use the mouse to select text in a program like Vim inside tmux?
Yes, but you must be in tmux copy‑mode. Click to place the cursor, then drag to highlight. Press Enter to copy. Vim itself can also be configured to use the mouse with set mouse=a, but tmux will still capture the event first.
Why does scrolling sometimes jump to the top of the pane?
This happens when the pane is not in copy‑mode; the scroll wheel is sent to the application running inside the pane, which may interpret it as a “home” command. Enter copy‑mode (Ctrl+b [) before scrolling to view the buffer.
Is mouse support available on remote SSH sessions?
It works if the remote terminal forwards mouse events. Most modern SSH clients do this automatically, but if you see no response, ensure the remote side runs a recent tmux version and that your local terminal is not stripping mouse escape sequences.
Can I disable mouse mode for a single pane only?
tmux does not provide per‑pane mouse toggles. The setting is global, affecting all windows and panes. You would need to turn mouse mode off, perform the pane‑specific action, then turn it back on.
How do I copy mouse‑selected text directly to the system clipboard?
Install a clipboard utility (xclip on Linux, pbcopy on macOS) and add a binding such as bind-key -T copy-mode-vi y run "tmux save-buffer - | xclip -i -selection clipboard". After selecting with the mouse, press y to send the content to the OS clipboard.