Overview
Format strings allow you to customize the output of many tmux commands and the appearance of the status line. Variables are enclosed in#{ and } and are replaced with their values.
Basic Syntax
Special Characters
string
Replaced by a single
#string
Replaced by a
, (use inside conditionals to escape commas)string
Replaced by a
} (use inside conditionals to escape closing braces)Single-Character Aliases
Some common variables have short aliases:#S→#{session_name}#W→#{window_name}#I→#{window_index}#P→#{pane_index}#D→#{pane_id}#F→#{window_flags}#T→#{pane_title}#H→#{host}#h→#{host_short}
Conditionals
Conditionals use the? prefix and allow branching based on variable values.
Basic Conditional
session_attached is non-zero, shows “attached”, otherwise “not attached”.
With Default
Nested Conditionals
Multiple Conditions
Escaping Inside Conditionals
Inside conditionals, use#, for comma and #} for closing brace:
Comparisons
String Comparisons
1 if true, 0 if false.
Logical Operators
Pattern Matching
Glob Pattern
Regular Expression
Content Search
Numeric Operations
Prefix withe and an operator:
Arithmetic
Floating Point
Addf flag for floating point operations:
Numeric Comparisons
String Manipulation
Length
Truncation
Padding
Repetition
Case Conversion
Quoting
Substitution
Time Formatting
Convert to String
Custom Format
Usestrftime format (escape % as %% if needed):
Character Conversion
Expansion
Single Expansion
Double Expansion with strftime
Literal
Loops
Loop Over Items
With Sort Order
With Different Formats
Provide two comma-separated formats (second for current/active item):Check Existence
Common Format Variables
Session Variables
#{session_name}(alias:#S): Name of session#{session_id}: Unique session ID (2, etc.)#{session_created}: Time session created#{session_activity}: Time of last activity#{session_attached}: Number of clients attached#{session_windows}: Number of windows#{session_group}: Name of session group#{session_grouped}: 1 if session in a group
Window Variables
#{window_name}(alias:#W): Name of window#{window_index}(alias:#I): Index of window#{window_id}: Unique window ID (@1, @2, etc.)#{window_active}: 1 if window is active#{window_flags}(alias:#F): Window flags#{window_panes}: Number of panes in window#{window_width},#{window_height}: Window dimensions#{window_layout}: Layout description#{window_zoomed_flag}: 1 if window is zoomed
Pane Variables
#{pane_id}(alias:#D): Unique pane ID (%1, %2, etc.)#{pane_index}(alias:#P): Index of pane#{pane_title}(alias:#T): Title of pane#{pane_current_path}: Current working directory#{pane_current_command}: Current command#{pane_width},#{pane_height}: Pane dimensions#{pane_active}: 1 if active pane#{pane_in_mode}: Number of modes pane is in#{pane_pid}: PID of first process in pane#{pane_tty}: Pseudo terminal of pane
Client Variables
#{client_name}: Name of client#{client_tty}: Pseudo terminal of client#{client_width},#{client_height}: Client dimensions#{client_session}: Name of attached session#{client_created}: Time client created#{client_activity}: Time of last activity#{client_prefix}: 1 if prefix key pressed#{client_readonly}: 1 if client is read-only
Server Variables
#{host}(alias:#H): Hostname#{host_short}(alias:#h): Hostname without domain#{pid}: Server PID#{socket_path}: Server socket path#{start_time}: Server start time#{version}: Server version#{server_sessions}: Number of sessions
Buffer Variables
#{buffer_name}: Name of buffer#{buffer_size}: Size in bytes#{buffer_created}: Time created#{buffer_sample}: Sample of buffer content
Other Variables
#{cursor_x},#{cursor_y}: Cursor position#{scroll_region_upper},#{scroll_region_lower}: Scroll region#{alternate_on}: 1 if alternate screen is on#{history_size}: Number of lines in history#{history_limit}: Maximum history lines#{copy_cursor_x},#{copy_cursor_y}: Copy mode cursor#{selection_present}: 1 if selection in copy mode