tmux Cheatsheet
Status Bar and Formats
Use this tmux reference while you build software engineering projects, review code, or refresh the syntax you reach for most.
Status Bar
set -g status on set -g status-position top set -g status-interval 5 set -g status-justify centre # left, centre, right set -g status-style "bg=default,fg=white" set -g status-left-length 40 set -g status-right-length 80 set -g status-left "#[bold]#S " set -g status-right "#{?client_prefix,PREFIX ,}%Y-%m-%d %H:%M" setw -g window-status-format " #I:#W " setw -g window-status-current-format "#[bold] #I:#W " setw -g window-status-current-style "fg=black,bg=white" set -g pane-border-style "fg=colour238" set -g pane-active-border-style "fg=colour250" set -g message-style "bg=white,fg=black"
Format Strings
Anything in #{} is interpolated, which is how the status bar and scripts read tmux state.
| Format | Value |
|---|---|
#S / #{session_name} | Session name |
#I / #{window_index} | Window index |
#W / #{window_name} | Window name |
#P / #{pane_index} | Pane index |
#{pane_id} | Unique pane id, like %3 |
#{pane_current_path} | The pane's working directory |
#{pane_current_command} | The running command |
#{pane_pid} | The pane's process id |
#{host} / #{host_short} | Hostname |
#{client_prefix} | 1 while the prefix is pending |
#{pane_synchronized} | 1 when panes are synced |
#{window_zoomed_flag} | 1 when zoomed |
#{session_windows} | Window count |
#{b:pane_current_path} | Basename of the path |
#{d:pane_current_path} | Dirname of the path |
#(shell command) | Output of a shell command, re-run each interval |
#{?cond,yes,no} | Conditional |
#{==:#{a},#{b}} | Comparison |
#[fg=red,bold] | Inline style |
set -g status-right "#{?window_zoomed_flag,ZOOM ,}#(whoami)@#{host_short} %H:%M" set -g status-left "#[bold]#S#[default] #{session_windows}w "
Keep #(shell command) cheap. It runs on every status-interval, so a slow command makes the whole status bar stutter.
Colors
set -g default-terminal "tmux-256color" set -ga terminal-overrides ",*256col*:Tc" set -ga terminal-features ",*:usstyle" # underline styles, tmux 3.2+
| Color syntax | Means |
|---|---|
colour0-colour255 | The 256-color palette |
#ff8800 | A 24-bit hex color |
red, green, blue, white, black | Named basics |
brightred and friends | The bright half |
default | Inherit from the terminal |
terminal | The terminal's own default |
tmux info | grep Tc # is true color detected echo $TERM # should be tmux-256color inside tmux
If colors look wrong inside tmux but fine outside, the culprit is almost always default-terminal plus a missing terminal-overrides line.
A Readable Status Bar
Everything below uses only built-in formats, so it works with no plugins.
set -g status-position bottom set -g status-justify left set -g status-interval 5 set -g status-left-length 30 set -g status-right-length 90 set -g status-style "bg=colour235,fg=colour250" set -g status-left "#[bold] #S #[default]" set -g status-right "#{?pane_synchronized,SYNC ,}#{?window_zoomed_flag,ZOOM ,}#[fg=colour245]#{b:pane_current_path} #[fg=colour250]%H:%M" setw -g window-status-format " #I #W " setw -g window-status-current-format "#[bg=colour250,fg=colour235,bold] #I #W " setw -g window-status-activity-style "fg=colour222" setw -g window-status-separator "" set -g pane-border-style "fg=colour238" set -g pane-active-border-style "fg=colour250" set -g message-style "bg=colour250,fg=colour235" set -g mode-style "bg=colour250,fg=colour235"
Pane Borders as Labels
set -g pane-border-status top set -g pane-border-format " #P: #{pane_current_command} "
With four panes open this is often more useful than the status bar, since each pane says what it is running.
Conditionals and Modifiers
| Syntax | Does |
|---|---|
#{?cond,then,else} | Conditional |
#{?#{==:#{a},b},y,n} | Compare two values |
#{b:var} | Basename |
#{d:var} | Dirname |
#{t:var} | Format a timestamp |
#{=10:var} | Truncate to 10 characters |
#{=-10:var} | Keep the last 10 characters |
#{s/foo/bar:var} | Substitute |
#{e|+|:1,2} | Arithmetic |
#{n:var} | Numeric length |
# Show the git branch, only when there is one set -g status-right "#(cd '#{pane_current_path}' && git branch --show-current 2>/dev/null) %H:%M" # Truncate a long path set -g status-right "#{=-30:pane_current_path}"
Keep the shell call cheap and add 2>/dev/null. It runs every status-interval seconds in every attached client, so a slow or noisy command makes the whole bar stutter.
Themes
| Theme | Install |
|---|---|
catppuccin/tmux | set -g @plugin 'catppuccin/tmux' |
dracula/tmux | set -g @plugin 'dracula/tmux' |
tmux-power | set -g @plugin 'wfxr/tmux-power' |
gruvbox | set -g @plugin 'egel/tmux-gruvbox' |
A theme is just a large set of status-* and *-style options. Reading one is a good way to learn the format language, and copying the twenty lines you like is often better than adding the dependency.