How to enable mouse support in tmux?

Quick Answer

To enable mouse support in tmux, add set -g mouse on to your .tmux.conf file. For temporary enabling during a session, use :set -g mouse on in tmux command mode.

$ echo "set -g mouse on" >> ~/.tmux.conf

Detailed Explanation

Mouse support in tmux allows you to use your mouse for various operations, including selecting and resizing panes, scrolling through terminal output, and selecting text for copying. This feature makes tmux more intuitive for newcomers and can speed up certain workflows.

Enabling mouse support permanently:

To enable mouse support permanently, add the following line to your ~/.tmux.conf file:

set -g mouse on

Then reload your tmux configuration:

$ tmux source-file ~/.tmux.conf

Enabling mouse support temporarily:

To enable mouse support for the current tmux session only, press your tmux prefix (default: Ctrl+b) followed by : to enter command mode, then type:

set -g mouse on

What mouse support enables:

  • Click to select panes
  • Drag pane borders to resize
  • Click on window names in the status bar to switch windows
  • Scroll wheel to scroll through terminal output
  • Click and drag to select text (enters copy mode automatically)

For older tmux versions (pre-2.1)

In older tmux versions, you needed multiple settings instead of the single command:

set -g mouse-select-pane on
set -g mouse-resize-pane on
set -g mouse-select-window on
set -g mode-mouse on

Tip for Terminal Selection

When mouse mode is enabled, you'll need to hold the Shift key while selecting text to bypass tmux and let your terminal handle the selection.