Skip to content

SOP-003: Window Operations

Fresh
FieldValue
Document IDSOP-003
Version1.1
StatusActive
tmux Version3.6b
Last Updated2026-05-26

Purpose

Create, navigate, and manage multiple windows within a tmux session.

Prerequisites

Window Concept

Procedure

Creating Windows

MethodCommand
KeyboardCtrl+b c
Commandtmux new-window
With nametmux new-window -n mywindow
At startuptmux new -s dev -n editor
bash
# Create window with specific name
Ctrl+b c        # Create window
Ctrl+b ,        # Rename it

# Or via command
tmux new-window -n "logs"
ShortcutAction
Ctrl+b nNext window
Ctrl+b pPrevious window
Ctrl+b 0-9Go to window number
Ctrl+b lLast active window
Ctrl+b wWindow list (interactive)

Window List View

Press Ctrl+b w for an interactive window/session browser:

(0)  0: editor* (2 panes)
(1)  1: server- (1 panes)
(2)  2: logs (1 panes)

Use arrow keys to navigate, Enter to select.

Renaming Windows

bash
# Keyboard shortcut
Ctrl+b ,        # Then type new name, press Enter

# Command
tmux rename-window newname

Closing Windows

MethodAction
Ctrl+b &Close window (with confirmation)
exitClose if single pane
:kill-windowForce close

Reordering Windows

bash
# Swap window positions
:swap-window -s 2 -t 1     # Swap window 2 with window 1

# Move current window left
:swap-window -t -1

# Move window between sessions
:move-window -s src_ses:win -t target_ses:win
:movew -s foo:0 -t bar:9

# Renumber windows (remove gaps)
:move-window -r
:movew -r

Window Workflow Example

Multi-Window Setup Script

Create a development environment with multiple windows:

bash
#!/bin/bash
# dev-setup.sh

SESSION="dev"

# Create session with first window named "editor"
tmux new-session -d -s $SESSION -n editor

# Create additional windows
tmux new-window -t $SESSION -n server
tmux new-window -t $SESSION -n logs
tmux new-window -t $SESSION -n git

# Send commands to windows
tmux send-keys -t $SESSION:editor 'vim .' C-m
tmux send-keys -t $SESSION:server 'npm run dev' C-m
tmux send-keys -t $SESSION:logs 'tail -f logs/app.log' C-m

# Select first window
tmux select-window -t $SESSION:editor

# Attach to session
tmux attach -t $SESSION

Verification

List windows in current session:

bash
# From command line
tmux list-windows

# Output example:
# 0: editor* (2 panes) [180x50]
# 1: server- (1 panes) [180x50]
# 2: logs (1 panes) [180x50]

Troubleshooting

Window numbers have gaps (0, 1, 5, 8)

Solution

Renumber windows to be sequential:

bash
:move-window -r

Or add to ~/.tmux.conf for automatic renumbering:

bash
set -g renumber-windows on

Can't switch to window number > 9

Solution

Use the window list instead:

bash
Ctrl+b w        # Then navigate with arrows

Or use the ' shortcut:

bash
Ctrl+b '        # Then type window number

See Also

Generated with AI-powered SOP Generator