Back to Docs
Recipe

tmux primer

Persistent terminal sessions, split panes, and detach/reattach workflows for developers who live in the shell.

Why tmux

SSH drops, laptop lids close, terminal tabs multiply. tmux keeps your shell state alive on the server. Detach from a session, log out, come back hours later — everything is exactly where you left it. Split panes let you tail logs, edit configs, and run builds side by side without spawning new SSH connections.

First session

$ tmux new -s dev

Creates a named session called “dev.” The green bar at the bottom confirms you are inside tmux.

Essential bindings

Prefix is Ctrl+b. Press it, release, then hit the command key.

dDetach session
cNew window
,Rename window
%Split vertically
"Split horizontally
xKill pane
[Scroll mode
sList sessions

Reattach

$ tmux ls

dev: 2 windows (created Tue)

$ tmux attach -t dev

List sessions with tmux ls, then attach by name. Your panes and scrollback are intact.

Config snippet

# ~/.tmux.conf

set -g mouse on

set -g default-terminal "screen-256color"

bind r source-file ~/.tmux.conf

Mouse support enables pane resizing and scroll with the wheel. Reload config live with prefix + r.