TL;DR:
- tmux’s killer feature is session persistence — SSH disconnect or close your terminal and your work is exactly where you left it
- Remap the prefix key from
Ctrl-btoCtrl-aimmediately;Ctrl-bis ergonomically hostile for heavy use - One session per project with named windows keeps context switching fast and deliberate
tmux solves two problems that every developer working in a terminal eventually hits: session loss and context fragmentation. When your SSH connection drops, a tmux session keeps running on the server. When you’re juggling three projects, named tmux sessions let you switch between them without losing state. These aren’t minor conveniences — over the course of a workday, they add up to significant recovered time.
What tmux Actually Gives You
A terminal emulator like iTerm2 or Alacritty manages the connection between your graphical interface and a shell process. When you close the terminal window, the shell dies. tmux adds a persistent layer between the shell and the terminal: sessions live in tmux’s server process, which keeps running regardless of what the terminal does.
The practical implications:
Detach and reattach. You can detach from a tmux session (Ctrl-a d), close your terminal, go home, open a new terminal, and re-attach to find everything exactly where you left it — processes still running, scrollback intact, panes arranged as you left them.
Remote work without SSH anxiety. When you’re working on a remote server, tmux means a dropped connection doesn’t kill your long-running process. ssh server, tmux attach, and you’re back. This is particularly useful if you’re SSHing into cloud VMs from a train with patchy connectivity.
Split panes without a GUI. Run your development server in one pane, your editor in another, your database CLI in a third — all in one terminal window, all connected to the same tmux session.
Essential Commands to Learn First
The default prefix key is Ctrl-b. Change it (see config section below). These are the commands you’ll use daily:
# Sessions
Ctrl-a d # Detach from session
tmux new -s name # New named session
tmux ls # List sessions
tmux attach -t name # Attach to session
# Windows (like tabs)
Ctrl-a c # New window
Ctrl-a , # Rename window
Ctrl-a n # Next window
Ctrl-a p # Previous window
Ctrl-a [0-9] # Jump to window by number
# Panes (splits)
Ctrl-a | # Vertical split (with config below)
Ctrl-a - # Horizontal split (with config below)
Ctrl-a [arrow] # Move between panes
Ctrl-a z # Zoom pane to full screen / unzoom
A .tmux.conf That Works
The default tmux configuration is usable but not optimised for developers. This config handles the most common friction points:
# ~/.tmux.conf
# Change prefix to Ctrl-a (screen-compatible, easier to type)
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Better split key bindings (easier to remember than % and ")
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# New windows open in current path
bind c new-window -c "#{pane_current_path}"
# Mouse support (click to select panes/windows, resize panes)
set -g mouse on
# Increase scrollback buffer
set -g history-limit 50000
# Start window numbering at 1 (easier to reach on keyboard)
set -g base-index 1
setw -g pane-base-index 1
# Renumber windows when one is closed
set -g renumber-windows on
# Enable true colour and italics
set -g default-terminal "xterm-256color"
set -ag terminal-overrides ",xterm-256color:RGB"
# Reload config with prefix + r
bind r source-file ~/.tmux.conf \; display "Config reloaded"
Session Management for Multiple Projects
The discipline that makes tmux actually useful: one session per project, named clearly. Each session has windows for different concerns within that project.
# Project layout
tmux new -s myapp # Create session "myapp"
# Window 1: "editor" → vim/neovim
# Window 2: "server" → npm run dev / python manage.py runserver
# Window 3: "db" → psql / redis-cli
# Window 4: "shell" → general purpose
When you switch to another project: Ctrl-a $ to rename your current session, then tmux new -s project2 for the next. Navigate between projects with tmux switch -t project2 or via tmux ls and attach.
tmux-resurrect is the plugin that persists sessions across machine restarts. Without it, tmux sessions survive terminal closures but not reboots. Install with TPM (tmux Plugin Manager) and your entire session layout is saved and restored automatically.
tmux + Vim Workflow
tmux and vim together form a complete development environment in a terminal. The pairing works because vim doesn’t need a GUI and tmux provides the session management, splits, and multi-project context vim lacks natively.
A common layout: vim occupies the left 70% of the terminal (zoomed full-screen when you’re deep in code), the right 30% holds a shell pane for running tests, git commands, and one-off commands. Toggle between the two with Ctrl-a z.
For navigation between vim splits and tmux panes without separate keystrokes, the vim-tmux-navigator plugin provides Ctrl-h/j/k/l to move across both vim and tmux splits uniformly. Once you’ve used it, going back to separate keybindings feels bizarre.
The Bottom Line
tmux pays for its learning curve in the first week. The moment you detach from a session on a remote server, come back the next morning, and re-attach to find everything exactly where you left it — you won’t work without it. Start with the .tmux.conf above, create named sessions for each active project, and the workflow becomes natural quickly.