Tutorial
tmux Tutorial
A practical tutorial on tmux, from your first session to the scripting and configuration that turn a terminal into a persistent, shareable workspace. Covers sessions, windows, panes, copy mode, configuration, status lines, scripting, plugins, and the workflows that make tmux worth the keystrokes.
Chapters
01
Introduction: What tmux Is and Why You'll Keep Using It
02
Sessions: Create, Attach, Detach, Repeat
03
Windows: Tabs That Survive Closing the Terminal
04
Panes: Splitting a Window Into Multiple Shells
05
Copy Mode: Scrolling, Searching, Selecting, Yanking
06
Command Mode: The:Prompt and What Sits Behind Every Key Binding
07
Configuration: Writing a .tmux.conf That Earns Its Keep
08
Status Line: The Bar at the Bottom, Made Useful
09
Scripting: Driving tmux From Shell Scripts
10
Plugins: TPM and the Short List Worth Installing
11
Workflows: SSH, Nesting, Editor Integration, Pair Programming
12
Best Practices: Idioms, Habits, and Knowing When Not to Use tmux
About this tutorial
A practical tour of tmux, from your first detached session to the configuration and scripting that turn a terminal into a persistent workspace you can share, suspend, and come back to.
Who This Is For
- Developers who live in the terminal and want their shells to survive an SSH drop
- Engineers who open six tabs every morning and want one keystroke that puts them back
- Anyone who has watched a colleague run
tmux attachand wondered why their day is so much calmer
Contents
Fundamentals
- Introduction: What tmux is, installing, your first session, the prefix key, detaching without panic
- Sessions: Creating, attaching, detaching, naming, listing, killing, switching between sessions
Core Concepts
- Windows: Creating, renaming, navigating, closing, and moving windows
- Panes: Splitting, navigation, resizing, zoom, swapping, and the built-in layouts
- Copy Mode: Entering copy mode, the vi bindings, selections, and system clipboard integration
- Command Mode: The
:prompt, chaining commands, targeting sessions and panes by name
Advanced
- Configuration:
.tmux.conf, options, key bindings, prefix rebinding, hooks - Status Line: Status bar anatomy, format strings, colours, and the segments worth showing
- Scripting:
send-keys, automating layouts, tmux inside shell scripts and project templates
Ecosystem
- Plugins: TPM, the short list worth installing, tmux-resurrect and continuum
Workflows
- Workflows: SSH, nested sessions, editor integration, pair programming, reusable session templates
Mastery
- Best Practices: Idioms, habits, anti-patterns, and knowing when to reach for something else
How to Use This Tutorial
- Read sequentially for a complete learning path
- Type out the commands. Every tmux command is a keystroke you'll repeat a hundred times this month
- Keep a scratch session open while reading. Detach, reattach, rename. The motions only stick through use
Quick Reference
Essential Commands
# Shell
tmux start a new session
tmux new -s work start a session named "work"
tmux ls list running sessions
tmux attach attach to the most recent session
tmux attach -t work attach to a specific session
tmux kill-session -t work kill a session
Inside tmux (default prefix is Ctrl-b)
<prefix> d detach (leave the session running)
<prefix> c create a new window
<prefix> n next window
<prefix> p previous window
<prefix> , rename the current window
<prefix> " split horizontally
<prefix> % split vertically
<prefix> z zoom the current pane
<prefix> [ enter copy mode
<prefix> ? list all key bindings
<prefix> : command prompt
Common Patterns
# Re-attach to your last session from the shell
tmux a
# Start a session with a specific layout
tmux new -s dev -d
tmux split-window -h -t dev
tmux split-window -v -t dev:0.1
tmux attach -t dev
# Kill every session at once
tmux kill-server
Learning Path Suggestions
Survive your first week (roughly 3 hours)
- Chapters 01 and 02 for sessions and the prefix key
- Chapter 03 for windows, chapter 04 for panes
- Use tmux for a day with nothing else
Get fluent (roughly 5 hours)
- Chapter 05 on copy mode, chapter 06 on the command prompt
- Chapter 07 to write a lean
.tmux.conf - Chapter 11 for the workflows that make tmux shine
Make tmux yours (roughly 4 hours)
- Chapter 08 to style the status line
- Chapter 09 to automate session templates
- Chapter 10 to add the two or three plugins worth adding
Why tmux?
- Persistence. SSH drops, laptop sleeps, terminal closes. Your session lives on. Re-attach and pick up
- Layout. Splits are first-class. One keystroke pops a shell next to your editor without new windows
- Scripting. A session is just a set of commands you can capture and replay. Start your whole dev environment with one script
- Portability. Install tmux on any Unix box and the muscle memory works the same
Additional Resources
- tmux official wiki
- tmux man page
- The Tao of tmux by Tony Narlock (free online)
- tpm: tmux plugin manager
- tmux-sensible (a shared baseline config)
- tmuxp and tmuxinator for session templates
tmux Version
This tutorial targets tmux 3.2+ and uses modern syntax (e.g. bind -N for named bindings). Most examples work on 2.9+. Features added after 3.2 are called out where relevant.