Skip to main content

Overview

A window in tmux occupies the entire screen and may be split into rectangular panes. Each window is a full-screen container that belongs to one or more sessions and can display multiple terminal panes. From the man page (tmux.1:48-62):
Each session has one or more windows linked to it. A window occupies the entire screen and may be split into rectangular panes, each of which is a separate pseudo terminal.

Window Architecture

From window.c:36-53, windows are implemented as:

Creating Windows

From window.c:294-339, window creation involves:
  1. Assigning a unique window ID (prefixed with @)
  2. Setting initial dimensions and pixel sizes
  3. Initializing the panes list
  4. Creating the options hierarchy
  5. Recording creation and activity time

Window Identification

Windows can be identified by:
  • Window ID: Prefixed with @ (e.g., @0, @1) - unique and unchanging
  • Window index: Numeric position in session (e.g., 0, 1, 2)
  • Window name: Descriptive name set by user or automatic naming
From the man page (tmux.1:787-845):

Special Window Tokens

From tmux.1:835-845:

Window Naming

From window.c:407-412:

Window Navigation

Key Bindings

From the man page default key bindings (tmux.1:307-348):
  • Prefix 0-9 - Select windows 0 to 9
  • Prefix c - Create a new window
  • Prefix , - Rename the current window
  • Prefix & - Kill the current window
  • Prefix n - Change to the next window
  • Prefix p - Change to the previous window
  • Prefix l - Move to the previously selected window
  • Prefix w - Choose the current window interactively
  • Prefix f - Prompt to search for text in open windows

Switching Windows

From session.c:417-466, window switching maintains a “last window” stack:

Window Linking

Windows can be linked to multiple sessions through the winlink structure. From window.c:98-133:
A window maintains a reference count and is only destroyed when no sessions link to it.

Window Resizing

From window.c:414-431, windows can be resized:
Window size is determined by the smallest attached client, unless size constraints are set:

Window Monitoring

Activity Monitoring

From window.c:288-292:
Enable activity monitoring:

Window Flags

From window.c:877-904, windows display flags in the status line:

Window Options

Windows have their own option scope:
Common window options:
  • automatic-rename - Automatically rename windows
  • aggressive-resize - Resize based on active client
  • monitor-activity - Monitor for activity
  • window-status-format - Format for window in status line
  • pane-base-index - Starting index for panes

Moving and Swapping Windows

Best Practices

  1. Use meaningful names: Name windows based on their purpose
  2. Organize logically: Keep related panes in the same window
  3. Monitor activity: Enable monitoring for background windows
  4. Set base index: Start window numbering at 1 for easier keyboard access
  5. Use window linking: Share windows between sessions when appropriate