How to create a custom status bar in tmux?

Quick Answer

Customize your tmux status bar by adding settings to your ~/.tmux.conf file. You can change colors, content, position, and format using various set-option commands.

set -g status-style bg=black,fg=white

Detailed Explanation

The tmux status bar (or status line) is the information bar typically displayed at the bottom of your tmux session. It shows session information, window list, and system stats. Customizing this bar can improve your workflow by adding useful information and making it match your preferred aesthetic.

Basic status bar customization:

Add these lines to your ~/.tmux.conf:

# Set status bar position (top/bottom)
set -g status-position bottom

# Set status bar colors
set -g status-style bg=black,fg=white

# Set status bar length
set -g status-left-length 40
set -g status-right-length 60

# Set content for left side of status bar
set -g status-left '#[fg=green]#S #[fg=yellow]#I:#P'

# Set content for right side of status bar
set -g status-right '#[fg=cyan]%a %d %b %R'

Status line elements:

The status line is divided into three sections:

  • status-left: Appears at the left side of the status bar
  • window list: Shows all windows in the current session (center section)
  • status-right: Appears at the right side of the status bar

Available variables:

You can use these variables in your status line format:

#SSession name
#IWindow index
#WWindow name
#PPane index
#HHostname
%aDay of week
%bMonth
%RTime (24-hour)

Customizing window list format:

Customize how windows appear in the status bar:

# Window status format
set -g window-status-format "#I:#W"
set -g window-status-current-format "#I:#W"

# Highlight active window
set -g window-status-current-style bg=red,fg=white,bold

Dystopian color scheme example:

A dark, cyberpunk-inspired status bar:

# Cyberpunk status bar
set -g status-style bg='#111111',fg='#00ff00'
set -g status-left '#[fg=#ff00ff,bold]#S #[fg=#00ffff]#I:#P #[default]| '
set -g status-right '#[fg=#ffff00]%H:%M #[fg=#ff00ff,bold]#H'
set -g window-status-current-style 'fg=#00ff00,bg=#000000,bold'
set -g window-status-current-format '#I:#W#F'
set -g window-status-style 'fg=#555555,bg=#000000'
set -g window-status-format '#I:#W#F'

Applying Changes

After editing your ~/.tmux.conf, reload it with:

Ctrl+b :source-file ~/.tmux.conf

Or from your shell:

$ tmux source-file ~/.tmux.conf