tmux Lesson Plan
A progressive curriculum to master tmux through hands-on practice.
Lesson 1: First Contact
Section titled “Lesson 1: First Contact”Goal: Understand what tmux does and run your first session.
Concepts
Section titled “Concepts”tmux is a terminal multiplexer. It lets you:
- Run multiple terminals in one window
- Detach sessions and reconnect later (survives SSH disconnects)
- Split your screen into panes
Exercises
Section titled “Exercises”-
Start and exit tmux
Terminal window tmux # Enter tmuxexit # Leave tmux (closes session) -
Create a named session
Terminal window tmux new -s practice -
Detach and reattach
Terminal window # Inside tmux, press: C-b d (Ctrl+b, then d)# You're back in your normal shell. The session lives on.tmux ls # See your sessiontmux attach -t practice # Reconnect -
Kill the session
Terminal window tmux kill-session -t practice
Checkpoint
Section titled “Checkpoint”You understand the session lifecycle: create → detach → attach → kill.
Lesson 2: Windows
Section titled “Lesson 2: Windows”Goal: Manage multiple terminals within one session.
Concepts
Section titled “Concepts”Windows are like browser tabs. Each window has its own shell. You see one window at a time.
Exercises
Section titled “Exercises”-
Create a session and add windows
Terminal window tmux new -s dev# C-b c Create window# C-b c Create another -
Navigate windows
Terminal window # C-b n Next window# C-b p Previous window# C-b 0 Go to window 0# C-b 1 Go to window 1# C-b w Interactive window list -
Name your windows
Terminal window # C-b , Rename current window# Type: editor -
Close a window
Terminal window # C-b & Kill window (confirms first)# Or just type: exit
Checkpoint
Section titled “Checkpoint”Create 3 windows named “editor”, “server”, “logs”. Jump between them by number.
Lesson 3: Panes
Section titled “Lesson 3: Panes”Goal: Split windows into multiple views.
Concepts
Section titled “Concepts”Panes divide a window into sections. All panes in a window display simultaneously.
C-b %splits left/right (think: % has two circles side by side)C-b "splits top/bottom (think: ” has two dots stacked)
Exercises
Section titled “Exercises”-
Split and navigate
Terminal window # Start freshtmux new -s panes# C-b % Split vertically (left/right)# C-b " Split horizontally (top/bottom)# C-b ←↑↓→ Move between panes -
Zoom a pane
Terminal window # C-b z Toggle fullscreen on current pane# C-b z Toggle back -
Close panes
Terminal window # C-b x Kill pane (with confirmation)# Or: exit -
Resize panes
Terminal window # C-b C-←↑↓→ Resize (small steps)# C-b M-←↑↓→ Resize (big steps)
Checkpoint
Section titled “Checkpoint”Create this layout:
+--------+--------+| | B || A +--------+| | C |+--------+--------+Start in window → split right → go to right pane → split down.
Lesson 4: Copy Mode
Section titled “Lesson 4: Copy Mode”Goal: Scroll history and copy text.
Concepts
Section titled “Concepts”Terminals lose scrollback when they fill. Copy mode lets you scroll, search, and yank text.
Exercises
Section titled “Exercises”-
Generate scrollback
Terminal window tmux new -s copyseq 1 500 # Print 500 lines -
Enter copy mode and scroll
Terminal window # C-b [ Enter copy mode# ↑ ↓ Scroll line by line# C-u C-d Scroll half pages# g Go to top# G Go to bottom# q Exit copy mode -
Search
Terminal window # C-b [ Enter copy mode# /250 Search forward for "250"# n Next match# N Previous match -
Copy and paste
Terminal window # C-b [ Enter copy mode# Space Start selection# (move cursor)# Enter Copy and exit# C-b ] Paste
Checkpoint
Section titled “Checkpoint”Copy lines 100-110 from your scrollback and paste them.
Lesson 5: Configuration
Section titled “Lesson 5: Configuration”Goal: Customize tmux to your preferences.
Exercises
Section titled “Exercises”-
Create a config file
Terminal window touch ~/.tmux.conf -
Add basic improvements
~/.tmux.conf # Start numbering at 1 (easier to reach)set -g base-index 1setw -g pane-base-index 1# Enable mouseset -g mouse on# Vi mode in copy modesetw -g mode-keys vi# Increase historyset -g history-limit 50000 -
Reload config
Terminal window # Inside tmux:# C-b :# source-file ~/.tmux.conf -
Add intuitive splits
Terminal window # ~/.tmux.conf (append)# Split with | and -bind | split-window -h -c "#{pane_current_path}"bind - split-window -v -c "#{pane_current_path}"
Checkpoint
Section titled “Checkpoint”Your config loads. C-b | splits horizontally. Mouse scrolling works.
Lesson 6: Session Workflow
Section titled “Lesson 6: Session Workflow”Goal: Use sessions for project organization.
Concepts
Section titled “Concepts”One session per project keeps contexts separate. Detach from one, attach to another.
Exercises
Section titled “Exercises”-
Create project sessions
Terminal window tmux new -s project-a -d # -d = detachedtmux new -s project-b -dtmux ls # See both -
Switch sessions
Terminal window tmux attach -t project-a# C-b s List sessions (interactive)# C-b ) Next session# C-b ( Previous session -
Session within session (avoid this)
Terminal window # If you see "sessions should be nested..." you're in tmux already.# Use C-b s to switch, don't nest.
Checkpoint
Section titled “Checkpoint”Maintain 2 project sessions. Switch between them without detaching.
Lesson 7: Scripting
Section titled “Lesson 7: Scripting”Goal: Automate your development environment.
Exercises
Section titled “Exercises”-
Create a dev script
~/bin/dev-session.sh #!/bin/bashSESSION="dev"# Exit if session existstmux has-session -t $SESSION 2>/dev/null && {tmux attach -t $SESSIONexit 0}# Create session with editor windowtmux new-session -d -s $SESSION -n "editor"tmux send-keys -t $SESSION:editor "nvim ." C-m# Create server windowtmux new-window -t $SESSION -n "server"tmux send-keys -t $SESSION:server "npm run dev" C-m# Create split window for git and teststmux new-window -t $SESSION -n "tools"tmux split-window -h -t $SESSION:toolstmux send-keys -t $SESSION:tools.0 "git status" C-m# Go back to editortmux select-window -t $SESSION:editor# Attachtmux attach -t $SESSION -
Make it executable
Terminal window chmod +x ~/bin/dev-session.sh -
Use target syntax
Terminal window # session:window.panetmux send-keys -t dev:editor.0 "echo hello" C-mtmux select-pane -t dev:tools.1
Checkpoint
Section titled “Checkpoint”Run your script. It creates your ideal workspace in one command.
Lesson 8: Advanced Tricks and Integration
Section titled “Lesson 8: Advanced Tricks and Integration”Goal: Power user techniques and terminal emulator integration.
Exercises
Section titled “Exercises”-
Synchronize panes (run command on all panes)
Terminal window # Create 3 panes# C-b :# setw synchronize-panes on# Type a command - it appears in all panes# setw synchronize-panes off -
Capture pane to file
Terminal window # C-b :# capture-pane -S -3000# save-buffer ~/debug.log -
Break pane to window
Terminal window # C-b ! Move current pane to its own window -
Join windows
Terminal window # C-b :# join-pane -s 2 -t 1 # Move window 2 into window 1 as pane -
Pipe pane output
Terminal window # C-b :# pipe-pane -o 'cat >> ~/output.log'# (all output goes to file until you run pipe-pane again)
Checkpoint
Section titled “Checkpoint”Sync 3 panes. Run uptime in all of them simultaneously.
Terminal Emulator Integration
Section titled “Terminal Emulator Integration”iTerm2’s Control mode (-CC) makes tmux feel native: tmux windows become iTerm
tabs, tmux panes become iTerm splits, and you get native scrollback, copy/paste,
and search. The session persists when you close iTerm. See
Terminal Emulators for a full comparison of
-CC mode vs standard tmux and guidance on when each approach fits.
-
Start an integrated session
Terminal window tmux -CC new -s integratediTerm takes over the UI. The window looks like a normal iTerm window.
-
Use native shortcuts
Terminal window # Instead of C-b c:Cmd+T # New tab (tmux window)# Instead of C-b % and C-b ":Cmd+D # Split rightCmd+Shift+D # Split down# Instead of C-b ←↑↓→:Cmd+Option+Arrow # Navigate panes# Instead of C-b x:Cmd+W # Close pane -
Scroll and search natively
Terminal window seq 1 500 # Generate output# Scroll with trackpad or mouse wheelCmd+F # Search (iTerm's search, not tmux copy mode) -
Detach and reattach through -CC
Terminal window # Option 1: Close iTerm entirely (Cmd+Q)# Option 2: tmux detach (or C-b d still works)# Later:tmux -CC attach -t integrated -
Configure iTerm for tmux
Open iTerm Preferences (Cmd+,) then General then tmux:
- “Open tmux windows as”: Tabs in a new window
- Check “Automatically hide the tmux client session”
- Check “When attaching, restore windows as tabs”
-
Mix integration with regular tmux
Terminal window # In iTerm with -CC:tmux -CC new -s work# From another terminal (SSH, different machine):tmux attach -t work # Regular attach works alongside -
Escape hatch
Terminal window # If you need to exit integration mode without detaching:Cmd+Shift+I # Detach from integration, return to normal iTerm
Final Checkpoint
Section titled “Final Checkpoint”Start tmux -CC new -s test. Create 3 tabs and split one into panes using only
Cmd shortcuts. Close iTerm entirely. Reopen and run tmux -CC attach -t test.
Everything should restore.
Practice Projects
Section titled “Practice Projects”Project 1: Monitoring Dashboard
Section titled “Project 1: Monitoring Dashboard”Create a session with:
- Window 1:
htop - Window 2: Split into 4 panes showing different log files
Project 2: Dev Environment
Section titled “Project 2: Dev Environment”Script that creates:
- Window “code”: editor
- Window “run”: split with server and file watcher
- Window “test”: test runner
- Window “git”: git status and lazygit
Project 3: SSH Resilience
Section titled “Project 3: SSH Resilience”SSH to a server, start tmux, run a long job, disconnect intentionally, reconnect, verify job continued.
Key Bindings Summary
Section titled “Key Bindings Summary”| Stage | Must Know |
|---|---|
| Beginner | C-b d C-b c C-b n C-b % C-b " C-b ←↑↓→ |
| Daily | C-b z C-b [ C-b s C-b w C-b , C-b x |
| Power | C-b : C-b ! C-b & sync-panes, scripting |
| iTerm | Cmd+T Cmd+D Cmd+Shift+D Cmd+Option+Arrow |
See Also
Section titled “See Also”- tmux — Quick reference: key bindings, config, scripting
- Terminal Emulators — iTerm2 vs Ghostty, tmux -CC integration
- Ghostty Lesson Plan — 8 lessons for the terminal emulator alongside tmux
- Operating Systems Lesson Plan — Processes, signals, and the environment tmux manages