tmux is a terminal multiplexer, and its configuration file, .tmux.conf, lets you customize nearly every aspect of its behavior and appearance.

Let’s see tmux in action. Imagine you’re working on a remote server and need to compile a large project. You can start tmux, detach from the session, and SSH out. Later, you can SSH back in and reattach to the exact same session, with your compilation still running in the background.

Here’s a basic tmux session running. We’ve split the window horizontally, then split the top pane vertically.

+-------------+-------------+
|             |             |
|             |             |
|             |             |
+-------------+-------------+
|                           |
|                           |
+---------------------------+

The real power comes from configuring .tmux.conf. Let’s say you want to make your tmux keybindings more ergonomic, moving them away from the default Ctrl-b prefix.

# Change the prefix key to Ctrl-a
set -g prefix C-a
unbind C-b
bind C-a send-prefix

# Easier window splitting
bind | split-window -h
bind - split-window -v

# Navigate panes with arrow keys
bind -n S-Left select-pane -L
bind -n S-Right select-pane -R
bind -n S-Up select-pane -U
bind -n S-Down select-pane -D

With these settings, instead of Ctrl-b then | to split horizontally, you’d press Ctrl-a then |. Similarly, Ctrl-a then Up Arrow will switch to the pane above. The -n flag in bind -n means these keybindings will be active without the prefix, which is useful for navigation.

The core problem tmux solves is managing multiple terminal sessions independently of your SSH connection or terminal emulator window. If your network connection drops, or you accidentally close your laptop lid, your tmux sessions keep running on the server. You can log back in and reattach to them.

Internally, tmux creates a server process. Your tmux client(s) connect to this server. The server manages all the windows, panes, and processes running within them. When you detach, the client disconnects, but the server continues running. When you reattach, a new client connects to the existing server.

Here’s how you might configure tmux to display the current time and battery status in the status bar:

# Set status bar to be at the bottom
set -g status-position bottom

# Customize status bar colors
set -g status-bg colour235 # Dark grey
set -g status-fg colour137 # Yellow

# Left side: Window list
set -g status-left '#[fg=colour137]Session: #S #[fg=colour172]Window: #I #[fg=colour248]#W'

# Right side: Time and battery
set -g status-right '#[fg=colour137]%Y-%m-%d %H:%M:%S #[fg=colour172,bold]Battery: #{battery_percentage}%%'

# Enable battery status (requires tmux >= 2.9 and a compatible system)
# Check your tmux version: tmux -V
# If battery isn't showing, ensure your system provides it via /sys/class/power_supply/BAT0/capacity (Linux)
# or similar. You might need to install a plugin like `tmux-battery`.
run-shell '~/.tmux/plugins/tmux-battery/battery.sh'

The #{battery_percentage} is a format string that tmux replaces with the actual battery level. The run-shell command is used to execute external scripts that can provide dynamic information to tmux, like battery status.

The most surprising thing about tmux is that you can have multiple tmux servers running on the same machine, each with its own independent set of sessions. This is achieved by specifying a different socket path for each server using the -S flag when starting tmux. For example, tmux -S /tmp/my_custom_tmux.sock attach would connect to a server listening on that specific socket, not the default /tmp/tmux-$(id -u)/default. This is incredibly useful for isolating different sets of projects or workflows.

Once you’re comfortable with basic configuration, you’ll want to explore tmux plugins, which significantly extend its functionality with features like fuzzy finding for windows or sessions, or more advanced status bar integrations.

Want structured learning?

Take the full Tmux course →