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.

Tutorial·Difficulty: Intermediate·12 chapters·Updated Apr 20, 2026

Chapters

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 attach and wondered why their day is so much calmer

Contents

Fundamentals

  1. Introduction: What tmux is, installing, your first session, the prefix key, detaching without panic
  2. Sessions: Creating, attaching, detaching, naming, listing, killing, switching between sessions

Core Concepts

  1. Windows: Creating, renaming, navigating, closing, and moving windows
  2. Panes: Splitting, navigation, resizing, zoom, swapping, and the built-in layouts
  3. Copy Mode: Entering copy mode, the vi bindings, selections, and system clipboard integration
  4. Command Mode: The : prompt, chaining commands, targeting sessions and panes by name

Advanced

  1. Configuration: .tmux.conf, options, key bindings, prefix rebinding, hooks
  2. Status Line: Status bar anatomy, format strings, colours, and the segments worth showing
  3. Scripting: send-keys, automating layouts, tmux inside shell scripts and project templates

Ecosystem

  1. Plugins: TPM, the short list worth installing, tmux-resurrect and continuum

Workflows

  1. Workflows: SSH, nested sessions, editor integration, pair programming, reusable session templates

Mastery

  1. Best Practices: Idioms, habits, anti-patterns, and knowing when to reach for something else

How to Use This Tutorial

  1. Read sequentially for a complete learning path
  2. Type out the commands. Every tmux command is a keystroke you'll repeat a hundred times this month
  3. 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)

  1. Chapters 01 and 02 for sessions and the prefix key
  2. Chapter 03 for windows, chapter 04 for panes
  3. Use tmux for a day with nothing else

Get fluent (roughly 5 hours)

  1. Chapter 05 on copy mode, chapter 06 on the command prompt
  2. Chapter 07 to write a lean .tmux.conf
  3. Chapter 11 for the workflows that make tmux shine

Make tmux yours (roughly 4 hours)

  1. Chapter 08 to style the status line
  2. Chapter 09 to automate session templates
  3. 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 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.