In tmux, a window is a single screen within a session. Each window occupies the entire terminal and can contain one or more panes. Windows are the primary organizational unit for grouping related tasks.
Think of windows like tabs in a web browser - they’re separate workspaces within the same session.
# Create window at specific indextmux new-window -t 5 -n config# Create window before current (-b) or after (-a)tmux new-window -a -n nexttmux new-window -b -n previous# Create window without making it currenttmux new-window -d -n background# Start in specific directorytmux new-window -c /var/log -n logs# Set environment variabletmux new-window -e EDITOR=vim# Print info about new windowtmux new-window -P -F "#{session_name}:#{window_index}"
# Move current window to index 5tmux move-window -t 5# Move window 3 to index 7tmux move-window -s 3 -t 7# Insert before (-b) or after (-a) targettmux move-window -a -t 3tmux move-window -b -t 3
# Link window from another sessiontmux link-window -s work:1 -t dev:3# Link to next available indextmux link-window -s work:editor# Kill existing window at target firsttmux link-window -k -s work:1 -t 2
# Create session in same group as existing sessiontmux new-session -t work -s work2# Windows are shared, but each session maintains its own:# - Current window# - Previous window # - Session options
# Unlink window from current sessiontmux unlink-window -t 3# Kill window if it's only linked to one sessiontmux unlink-window -k -t 3
A window must be linked to at least one session. You cannot unlink a window from its only session unless you use the -k flag, which will destroy the window.
# Kill current windowtmux kill-window# Kill specific windowtmux kill-window -t 3tmux killw -t editor# Kill all windows except specifiedtmux kill-window -a -t 2 # Kill all but window 2
# List windows in current sessiontmux list-windowstmux lsw# List windows in specific sessiontmux list-windows -t work# Custom formattmux list-windows -F "#{window_index}: #{window_name}"# Filter windowstmux list-windows -f '#{==:#{window_active},1}'# Sort windowstmux list-windows -O name # By nametmux list-windows -O creation # By creation time
# Set for all windows globallyset-option -g -w <option> <value># Set for current windowset-option -w <option> <value># Set for specific windowset-option -w -t :3 <option> <value>
# Enable/disable automatic window renamingset-option -w automatic-rename on# Format for automatic nameset-option -w automatic-rename-format '#{b:pane_current_path}'# Allow programs to rename windowsset-option -w allow-rename on
Window Size
# Window sizing behaviorset-option -w window-size latest # Size to latest clientset-option -w window-size largest # Size to largest clientset-option -w window-size smallest # Size to smallest clientset-option -w window-size manual # Manual sizing# Enable aggressive resizeset-option -w aggressive-resize on
Activity Monitoring
# Monitor for activityset-option -w monitor-activity on# Monitor for silence (in seconds)set-option -w monitor-silence 30# Monitor for bellset-option -w monitor-bell on
Mode Keys
# Set vi or emacs key bindings for copy modeset-option -w mode-keys viset-option -w mode-keys emacs