SOP-003: Window Operations
Fresh| Field | Value |
|---|---|
| Document ID | SOP-003 |
| Version | 1.1 |
| Status | Active |
| tmux Version | 3.6b |
| Last Updated | 2026-05-26 |
Purpose
Create, navigate, and manage multiple windows within a tmux session.
Prerequisites
Window Concept
Procedure
Creating Windows
| Method | Command |
|---|---|
| Keyboard | Ctrl+b c |
| Command | tmux new-window |
| With name | tmux new-window -n mywindow |
| At startup | tmux 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"Navigating Windows
| Shortcut | Action |
|---|---|
Ctrl+b n | Next window |
Ctrl+b p | Previous window |
Ctrl+b 0-9 | Go to window number |
Ctrl+b l | Last active window |
Ctrl+b w | Window 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 newnameClosing Windows
| Method | Action |
|---|---|
Ctrl+b & | Close window (with confirmation) |
exit | Close if single pane |
:kill-window | Force 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 -rWindow 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 $SESSIONVerification
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 -rOr add to ~/.tmux.conf for automatic renumbering:
bash
set -g renumber-windows onCan't switch to window number > 9
Solution
Use the window list instead:
bash
Ctrl+b w # Then navigate with arrowsOr use the ' shortcut:
bash
Ctrl+b ' # Then type window number