tmux reference

   |   4 minute read   |   Using 711 words

If you spend a lot of time in the terminal, you’ve probably heard of tmux. It’s a terminal multiplexer — a tool that lets you create multiple terminal sessions inside a single window, detach from them, and reattach later, even across different machines or after an SSH disconnection. In short, it makes your terminal workflow persistent, flexible, and powerful.

I’ve been using tmux daily for years, and it’s one of those tools that feels indispensable once you get comfortable with it. This post is a deep dive into what tmux is, why it matters, and how to use it effectively — written as a friendly guide rather than a dry man page.

What Is tmux and Why Should You Care?

At its core, tmux lets you:

  • Run multiple terminal “panes” (split screens) in one window
  • Group panes into “windows” (like browser tabs)
  • Group windows into “sessions” that can be detached and reattached
  • Keep long-running processes alive even if your SSH session drops

Think of it as a session manager for your terminal. You start a session, open several windows and panes (e.g., one for editing code, one for running tests, one for logs), detach, go home, and reattach on your laptop — everything is exactly where you left it.

Compared to its older cousin screen, tmux has a more modern design, better scripting support, and far more customization options.

Getting Started

Install tmux (most package managers have it):

# Debian/Ubuntu
sudo apt install tmux

# macOS
brew install tmux

# Fedora
sudo dnf install tmux

Start a new session:

tmux

Or give it a name:

tmux new -s workspace

You’ll see a green status bar at the bottom. That’s the tmux status line.

The default prefix key is Ctrl-b. You’ll use it for almost every command.

Core Concepts: Sessions, Windows, Panes

  • Session: A collection of windows. You can have many sessions and switch between them.
  • Window: Like a tab. Contains one or more panes.
  • Pane: A split region running its own shell.

Basic Navigation

ActionKey BindingDescription
Create new windowCtrl-b cNew tab
Next windowCtrl-b nGo forward
Previous windowCtrl-b pGo backward
Select window by numberCtrl-b 0-9Jump to window 0–9
Split pane horizontallyCtrl-b %Left/right split
Split pane verticallyCtrl-b "Top/bottom split
Move between panesCtrl-b ArrowArrow keys
Close paneCtrl-b xKill current pane
Detach from sessionCtrl-b dLeave tmux running in background

To reattach later:

tmux attach          # attaches to the most recent session
tmux attach -t workspace   # attach to named session

Essential Key Bindings You’ll Use Every Day

Here are the ones I use constantly:

  • Ctrl-b , — rename current window
  • Ctrl-b [ — enter copy mode (scroll with Vim keys or arrow keys)
  • Ctrl-b ] — paste buffer
  • Ctrl-b ? — show all key bindings (super useful!)
  • Ctrl-b : — command prompt (type commands manually)
  • Ctrl-b z — zoom pane (toggle full-screen)
  • Ctrl-b Space — cycle through preset layouts

Configuring tmux

The real power comes from ~/.tmux.conf. Here’s a solid starter config I use:

# Use Ctrl-a instead of Ctrl-b (more comfortable)
set -g prefix C-a
unbind C-b
bind C-a send-prefix

# Start window/pane indexing at 1
set -g base-index 1
setw -g pane-base-index 1

# Better colors
set -g default-terminal "tmux-256color"

# Vim-style copy mode
setw -g mode-keys vi
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-selection-and-cancel

# Status bar customization
set -g status-style bg=default,fg=colour223
set -g status-left "#[fg=green][#S] "
set -g status-right "#[fg=cyan]%H:%M %d-%b-%y"

# Mouse support (optional, but nice)
set -g mouse on

Reload config without restarting:

tmux source-file ~/.tmux.conf

Advanced Features Worth Knowing

  • Layouts: Ctrl-b M-1 to M-5 for preset arrangements (even-horizontal, main-vertical, etc.)
  • Session groups: Link windows across sessions with new-session -t existing-group
  • Control mode: For scripting tmux from other programs
  • Plugins: The tmux plugin manager (tpm) + plugins like tmux-resurrect and tmux-continuum can save/restore sessions automatically

Common Workflows

  1. Development workspace

    tmux new -s dev
    # Split into editor | server | logs
    Ctrl-b %   # split vertically
    Ctrl-b "   # split horizontally
    
  2. Remote work
    Start tmux on a remote server, work all day, detach, go home, tmux attach from laptop — everything persists.

  3. Pair programming
    Multiple people can attach to the same session.



denis256 at denis256.dev