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
# from inside a session
Ctrl+b c # 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:
Ctrl+b , # rename current window
Or from command line:
tmux rename-window -t work:0 "editor"
tmux rename-window -t work:1 "server"
Navigating Windows
| Shortcut | Action |
|---|---|
Ctrl+b n | Next window |
Ctrl+b p | Previous window |
Ctrl+b 0-9 | Jump to window by number |
Ctrl+b w | Interactive window list |
Ctrl+b l | Last (previously active) window |
Ctrl+b ' | 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
# from inside (shortcut)
Ctrl+b . # 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:
# monitor window for activity (bell / visual alert)
Ctrl+b M # toggle monitor activity on current window
# monitor window for silence (no output for N seconds)
Ctrl+b ! # (via tmux command prompt)
: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 |