TechBuzzPro

Enable and Use tmux Mouse Mode – Quick Guide

· 6 min read · Windows & PC

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

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

  1. Open your tmux configuration file. In most setups the file lives at ~/.tmux.conf. If it does not exist, create it with touch ~/.tmux.conf.
  2. Add the mouse option. Append the line set -g mouse on to the file. This tells tmux to enable mouse handling for all supported actions.
  3. Reload the configuration. Inside an active tmux session press the tmux prefix (by default Ctrl+b) then type : to open the command prompt and enter source-file ~/.tmux.conf. Alternatively, you can restart tmux by exiting all sessions (exit or Ctrl+d) and starting a new one with tmux.
  4. Test pane selection. Click inside any pane. The pane should gain a highlighted border, indicating that tmux has captured the mouse click.
  5. 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.
  6. 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).
  7. Enter copy‑mode with a click. Right‑click (or left‑click while holding Shift in some terminals) to place the cursor at a specific line. Then use the mouse to drag and select text. Press Enter to copy the selection to tmux’s buffer.
  8. 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.
  9. Toggle mouse mode on the fly. If you need to disable mouse support temporarily, press Ctrl+b : and type set -g mouse off. Re‑enable it later with the same command, using on instead of off.
  10. Persist the setting across machines. If you work on multiple hosts, copy your .tmux.conf file 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 on without 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 mouse option and require separate flags (mode-mouse, mouse-select-pane, etc.). Upgrade tmux if the single mouse on line 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 any bind-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 configure set -g mouse-select-pane on etc.). 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 vi in your config so that once you’re in copy‑mode you can still use h j k l keys alongside the mouse.
  • Use set -g mouse on with setw -g mode-mouse on for 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-namespace utility on macOS or use xclip/xsel on Linux, then bind bind-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.conf to ~/.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:

  1. Restart tmux. Exit all sessions and start a fresh one. This clears any stale configuration that might linger after a reload.
  2. Verify tmux version. Run tmux -V. Versions 2.1+ support the single mouse on flag. If you see an older version, update via your package manager (e.g., brew install tmux on macOS or sudo apt install tmux on Debian/Ubuntu).
  3. Check terminal mouse reporting. Inside tmux, press Ctrl+b : and type show-options -g mouse. It should display mouse on. Then, in a normal shell (outside tmux), run cat and scroll or click; you should see escape sequences like ^[[M. If not, enable mouse reporting in your terminal preferences.
  4. 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.
  5. Inspect custom key bindings. Search your .tmux.conf for any bind-key -n Mouse lines. Comment them out, reload, and see if default mouse behaviour returns.
  6. Test with a minimal config. Start tmux with tmux -f /dev/null, then manually enable mouse with Ctrl+b : set -g mouse on. If it works, the problem lies in your regular config file.
  7. Update the terminal emulator. Older terminal builds may have bugs that prevent proper mouse event forwarding. Upgrade to the latest stable release.
  8. 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.