The set
command in tmux is used to configure options during runtime or in your configuration file. Use it with Ctrl+b : followed by set OPTION VALUE
. For global options, use set -g
, for window options use set -w
, and for server options use set -s
.
set -g mouse on
The set
command is one of the most commonly used commands in tmux, allowing you to configure virtually every aspect of tmux's behavior. It works both in the command prompt during runtime and in your ~/.tmux.conf
configuration file.
# Basic syntax set OPTION VALUE # Set a global option set -g OPTION VALUE # Set a window option set -w OPTION VALUE # Or equivalently set-window-option OPTION VALUE # Set a server option set -s OPTION VALUE
The scope flags (-g, -w, -s) determine which level of tmux configuration you're modifying:
-g
) apply to all sessions-w
) apply to all windows in a session-s
) apply to the tmux server process# Enable mouse support set -g mouse on # Set the prefix key to Ctrl+a set -g prefix C-a # Set terminal color support set -g default-terminal "screen-256color" # Increase scrollback buffer size set -g history-limit 10000 # Set window numbering to start from 1 instead of 0 set -g base-index 1 # Set pane numbering to start from 1 set -g pane-base-index 1 # Set status bar colors set -g status-style "bg=black,fg=white"
These examples show some of the most commonly used set commands that tmux users configure.
You can use the set command during an active tmux session by entering the command prompt:
# Press Ctrl+b followed by : to access the command prompt # Then type your set command set -g mouse on
Changes made this way are temporary and will be lost when the tmux server restarts. To make them permanent, add them to your ~/.tmux.conf
file.
For boolean options, you can toggle them on and off:
# Turn on mouse mode set -g mouse on # Turn off mouse mode set -g mouse off
You can create key bindings to toggle options in your configuration:
# Add to ~/.tmux.conf - Press Ctrl+b m to toggle mouse mode bind m set -g mouse \; display "Mouse mode toggled"
View the current value of any tmux option with the show-options command:
# Show all global options Ctrl+b :show-options -g # Show a specific option Ctrl+b :show-options -g mouse
This is useful for checking your current configuration or troubleshooting issues.
For complex key bindings or scripts, you can set multiple options at once using semicolons:
# Set multiple options with one command set -g status-style "bg=black,fg=white" \; set -g mouse on \; set -g history-limit 5000
Note the backslash before each semicolon when used in a configuration file. When entered at the command prompt, omit the backslashes.