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.
Install tmux with your package manager. On macOS:
brew install tmuxOn Ubuntu/Debian:
sudo apt install tmuxtmux -V)Tmux has a nested hierarchy: sessions contain windows, windows contain panes. Understanding this is the key to everything else.
tmux new -s work — create a session named "work"tmux ls — list all sessionstmux attach -t work — reattach to the "work" sessiontmux kill-session -t old — destroy a sessionWindows 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 sessionThe 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.
tmux -S /tmp/pair lets two people share a sessiontmuxinator or a shell script to recreate your ideal layoutset -g mouse on to your tmux.conf to click-select panes and scroll naturally. It changes everything.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"Common issues and their fixes:
default-terminal "tmux-256color" and add the terminal-overrides lineset -g set-clipboard on and install reattach-to-user-namespace on macOStmux source ~/.tmux.conf or use your reload keybindingCtrl-b [, then use Page Up/DownYou've mastered the basics. Here's how to go further: