Tmux
Back to Terminal
TmuxIntermediate18 min

Tmux Terminal Multiplexer Guide: Sessions, Panes, and Configuration

Why a Terminal Multiplexer?

Tmux is a terminal multiplexer — it lets you run multiple terminal sessions in one window, detach and reattach sessions, and split panes. If you've ever lost work because an SSH connection dropped, tmux solves that permanently.

This guide covers everything: sessions, panes, windows, configuration, and the workflow patterns that make tmux indispensable.

By the end of this 18-min guide, you'll never need to open more than one terminal window again.

Installing Tmux & First Session

Install tmux with your package manager. On macOS:

brew install tmux

On Ubuntu/Debian:

sudo apt install tmux

Sessions, Windows & Panes

Tmux has a nested hierarchy: sessions contain windows, windows contain panes. Understanding this is the key to everything else.

Windows are like tabs. Panes are splits within a window. The default prefix is Ctrl-b — you press it, release, then press the next key.

# Key bindings (prefix is Ctrl-b)
Ctrl-b c        # new window
Ctrl-b ,        # rename window
Ctrl-b 0-9      # switch to window N
Ctrl-b %        # split pane vertically
Ctrl-b "        # split pane horizontally
Ctrl-b o        # cycle to next pane
Ctrl-b d        # detach session

Daily Session Workflow

The real power of tmux is persistent sessions. Start a session on a remote server, run a build, detach, go home, and reattach to see the result.

Pro tip: Add set -g mouse on to your tmux.conf to click-select panes and scroll naturally. It changes everything.

Custom Keybindings & Prefix

Your ~/.tmux.conf is where tmux becomes yours. Here's a battle-tested config to start with:

# Change prefix to Ctrl-a (closer to home row)
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# Split panes more intuitively
bind | split-window -h
bind - split-window -v
# Reload config with Ctrl-a r
bind r source-file ~/.tmux.conf \; display "Reloaded!"
# Mouse support
set -g mouse on
# 256 colors
set -g default-terminal "tmux-256color"
set -ag terminal-overrides ",xterm-256color:RGB"

Config Not Loading?

Common issues and their fixes:

Tmux as Second Nature

You've mastered the basics. Here's how to go further:

← PreviousKarabiner-Elements Tutorial: Remap macOS Keyboard and Build a Hyper KeyNext →fzf and ripgrep Integration: Fuzzy Search Your Codebase from the Terminal