What Is tmux and Why Use It?
tmux (terminal multiplexer) lets you run multiple terminal sessions inside a single window, split your screen into panes, and — most importantly — keep sessions alive when you disconnect. SSH into a server, start a tmux session, disconnect, reconnect hours later, and everything is exactly where you left it. For remote development and remote work, this is indispensable.
Core Concepts: Sessions, Windows, Panes
Sessions are the top-level container — create one per project (tmux new -s projectname). Windows are tabs within a session — one for code, one for server logs, one for git. Panes are splits within a window — run your editor alongside a terminal. The hierarchy: sessions contain windows, windows contain panes.
Essential Commands
All commands start with the prefix key (Ctrl+b by default): Ctrl+b c creates a new window. Ctrl+b % splits vertically, Ctrl+b " splits horizontally. Ctrl+b d detaches the session. tmux attach -t projectname reattaches. Ctrl+b [ enters scroll mode (navigate with arrow keys, q to exit). Ctrl+b z zooms a pane to full screen.
Customizing.tmux.conf
The default keybindings are functional but awkward. Most developers customize them:
# ~/.tmux.conf
set -g prefix C-a # Change prefix to Ctrl+a
unbind C-b
bind | split-window -h # Intuitive split bindings
bind - split-window -v
set -g mouse on # Enable mouse support
set -g base-index 1 # Start window numbering at 1
set -g default-terminal "tmux-256color"
set -sg escape-time 0 # No delay for escape keyA Developer Workflow with tmux
A typical setup: Session "webapp" with three windows. Window 1: Neovim editor filling the screen. Window 2: split into panes — dev server on top, database console on bottom. Window 3: git operations and deployment scripts. Switch between windows with Ctrl+a 1/2/3. This replaces a tabbed terminal emulator with something more powerful and persistent.
tmux Plugins with TPM
TPM (tmux Plugin Manager) adds functionality: tmux-resurrect saves and restores sessions across system restarts. tmux-continuum auto-saves sessions every 15 minutes. tmux-yank copies to system clipboard. tmux-sensible provides universally agreed-upon defaults. Install TPM, add plugins to .tmux.conf, and press prefix + I to install.
tmux for Pair Programming
Two developers can attach to the same tmux session on a shared server for real-time pair programming. Both see the same terminal, can type, and collaborate in real-time. Tools like tmate make this easier by generating shareable URLs for your tmux session — no SSH key exchange needed.
Conclusion
tmux transforms your terminal from a single-purpose window into a persistent, multi-tasking workspace. The learning curve is a few days; the productivity gains last years. Start with sessions and windows, then add panes and customization. Combined with Neovim, it's the fastest development environment available.