Tmux formats use #{variable_name}
syntax to insert dynamic information. Use #{session_name}
for session name, #{window_name}
for window name, and #{pane_current_path}
for current directory in status bars and commands.
set-option -g status-right '#{session_name} #{window_index}'
Tmux formats are a powerful templating system that allows you to insert dynamic information into status bars, window titles, and command outputs. They use #{}
syntax to reference session, window, and pane properties.
# Session info #{session_name} # Session name #{session_windows} # Number of windows # Window info #{window_index} # Window number (0, 1, 2...) #{window_name} # Window name #{window_panes} # Number of panes # Pane info #{pane_current_path} # Current directory #{pane_current_command} # Running command #{pane_index} # Pane number
# Basic session and time display set-option -g status-left '#{session_name}: ' set-option -g status-right '%H:%M %d-%b' # Show current directory set-option -g status-right '#{b:pane_current_path} | %H:%M' # Window list with pane count set-option -g window-status-format '#{window_index}:#{window_name}' set-option -g window-status-current-format '[#{window_index}:#{window_name}]'
Use #{?condition,true_value,false_value}
for conditional display:
# Show asterisk for active window #{window_index}:#{window_name}#{?window_active,*,} # Conditional colors #{?window_active,#[fg=red],#[fg=white]}#{window_name}#[default] # Show pane count only if more than 1 #{window_name}#{?#{>:#{window_panes},1}, [#{window_panes}],}
# Truncate to 15 characters #{=15:pane_current_path} # Get basename of path #{b:pane_current_path} # Get directory name #{d:pane_current_path} # Search and replace #{s/home/~/:pane_current_path}
# Display current info tmux display-message '#{session_name}: #{window_index}/#{session_windows}' # List windows with custom format tmux list-windows -F '#{window_index}: #{window_name} (#{window_panes} panes)' # Use in key bindings bind-key i display-message 'Window: #{window_name}, Pane: #{pane_index}'
Use #{b:pane_current_path}
instead of #{pane_current_path}
in your status bar to show just the directory name instead of the full path.
# Comprehensive status bar in ~/.tmux.conf set-option -g status-left '#[fg=green]#{session_name}#[default] ' set-option -g status-right '#[fg=blue]#{b:pane_current_path}#[default] | #[fg=yellow]%H:%M#[default]' set-option -g window-status-format '#{window_index}:#{=10:window_name}' set-option -g window-status-current-format '#[fg=red,bold]#{window_index}:#{=10:window_name}#[default]'