Windows Basics
Windows in tmux are like browser tabs: each one fills the whole terminal area and runs independent shell processes.
Learning Focus
Use this lesson to get comfortable creating, switching, and naming windows for organized multi-task workflows.
Creating Windows
| Default Shortcut | Modification Shortcut | Action |
|---|---|---|
Ctrl+b c | Ctrl+Space W | New window (auto-numbered) |
From the command line:
tmux new-window -t work -n "logs"
tmux new-window -t work:3 -n "deploy" # at specific index
Window Naming
By default, windows show the current command name. Rename them to be descriptive:
| Default Shortcut | Modification Shortcut | Action |
|---|---|---|
Ctrl+b , | Prefix e w | Rename current window |
Or from command line:
tmux rename-window -t work:0 "editor"
tmux rename-window -t work:1 "server"
Navigating Windows
| Default Shortcut | Modification Shortcut | Action |
|---|---|---|
Ctrl+b n | Alt+PageDown | Next window |
Ctrl+b p | Alt+PageUp | Previous window |
Ctrl+b 0-9 | Alt+1/2/3 or Ctrl+Space 0-9 | Jump to window by number |
Ctrl+b w | Ctrl+Space w | Interactive window list |
Ctrl+b l | Ctrl+Space l | Last (previously active) window |
Ctrl+b ' | Ctrl+Space ' | Prompt for window index |
Moving and Reordering Windows
# swap window 1 and window 3
tmux swap-window -s 1 -t 3
# move window to index 0
tmux move-window -t 0
| Default Shortcut | Modification Shortcut | Action |
|---|---|---|
Ctrl+b . | Ctrl+Space . | Prompt to move window to a new index |
Closing Windows
# close current window — exit all panes
exit
# force kill from outside
tmux kill-window -t work:2
note
A window closes automatically when all panes inside it exit.
Monitoring Windows
Tmux can alert you when activity happens in a background window:
| Default Shortcut | Modification Shortcut | Action |
|---|---|---|
Ctrl+b M | Ctrl+Space M | Toggle monitor activity on current window |
Ctrl+b ! | Ctrl+Space ! | Open command prompt for silence monitoring |
:monitor-silence 30
Window List in the Status Bar
The status bar shows all windows:
[work] 0:editor* 1:server- 2:git "server01" 04:10
│ │ │ │ │
Session # Name # Name *=active, -=last used
Common Workflow: Dev Setup
dev-windows-setup.sh
#!/bin/bash
SESSION="work"
# create session with first window
tmux new -s "$SESSION" -n "editor" -d
# add more windows
tmux new-window -t "$SESSION" -n "server"
tmux new-window -t "$SESSION" -n "git"
tmux new-window -t "$SESSION" -n "logs"
# send initial commands to each window
tmux send-keys -t "$SESSION:server" "cd /srv/myapp && npm run dev" Enter
tmux send-keys -t "$SESSION:logs" "tail -f /var/log/syslog" Enter
# attach — starting on the editor window
tmux select-window -t "$SESSION:editor"
tmux attach -t "$SESSION"
Common Pitfalls
| Pitfall | Symptom | Fix |
|---|---|---|
| Not naming windows | Hard to find the right one | Use Ctrl+b , immediately after creating |
| Closing session when only one window left | Session killed | Detach instead: Ctrl+b d |
| Too many windows | Cluttered status bar | Group related tasks per session instead |