How to create a tmux theme, load changes and define styles and formats for the panes and status bar
There are example templates available in the /usr/share/doc/tmux/examples
folder which are a really good starting point and help you understand how to configure your own theme
~/.tmux.conf
file directly and add your styles or you can save the theme separately and load it from the conf file.Add this line to the bottom of ~/.tmux.conf
:
1run-shell ~/file/path/flatui-theme.tmux
This approch is safer as you are not editing your conf file directly and won’t mess it up by chance. It is also good when you’re testing multiple themes. You can just comment/uncomment the line that loads a theme instead of overwriting the entire .tmux.conf
file every time
tmux
1tmux source-file ~/.tmux.conf
1bind r source-file ~/.tmux.conf \; display "Reloaded ~/.tmux.conf"
tmux
and start it again1# kill all sessions
2<prefix> &
tmux
and see if it is giving any errors-g
shows the styles for the current pane
-T
sets the title for the current pane
You can save color variables like Bash HIGHLIGHT="#3fcfff"
and use the $HIGHLIGHT
You can use terminal colors (black, red, green, yellow, blue, magenta, cyan, white etc.), Hexadecimal (’#ffffff’, all 6 digits, no #FFF shorthand, needs to be in commas), and 256 colour set: (colour0 till colour256)
Possible color values:
'#ffffff'
, all 6 digits, no #FFF shorthand, needs to be in commas)black
, red
, green
, yellow
, blue
, magenta
, cyan
, white
)colour0
till colour256
You can use the default
keyword to use default colors.
Possible Attribute values:
none
, bright
, bold
, dim
, underscore
, blink
, reverse
(reverses the FG and BG colors), hidden
, italics
, strikethrough
(bold, underscore and reverse worked for me)noreverse
, noitalics
etc. 1# Multiple ways of defining style
2# --------------------------------
3
4# 1. Define background `bg` and foreground `fg` separately
5set-window-option -g window-status-current-fg white
6set-window-option -g window-status-current-bg default
7
8# 2. One-liner
9set -g pane-border-style 'fg=#585858, bg=#262626'
10
11# 3. Use color variables (double quotes "" are important to get the values)
12set -g status-style "fg=${CLOUDS}, bg=${TURQUOISE}"
1# Examples with colors AND attributes
2fg=yellow,bold,underscore,blink
3bg=black,fg=default,noreverse
" "
window-style
and window-active-style
are used to style a pane. 1# Color Variables
2WINDOW_FG="#95a5a6"
3WINDOW_BG="black"
4WINDOW_ACTIVE_FG="#ecf0f1"
5WINDOW_ACTIVE_BG="black"
6
7# Inactive Pane
8set -g window-style "fg=${WINDOW_FG}, bg=${WINDOW_BG}"
9
10# Active Pane
11set -g window-active-style "fg=${WINDOW_ACTIVE_FG}, bg=${WINDOW_ACTIVE_BG}"
select-pane
option with the -P
flag1select-pane -t:.1 -P 'bg=red'
Within a configuration file, commands may be made conditional by surrounding them with
%if
and%endif
lines. Additional %elif and %else lines may also be used. The argument to%if
and%elif
is expanded as a format and if it evaluates to false (zero or empty), subsequent lines are ignored until the next%elif
,%else
or%endif
. For example:
1%if #{==:#{host},myhost}
2set -g status-style bg=red
3%elif #{==:#{host},myotherhost}
4set -g status-style bg=green
5%else
6set -g status-style bg=blue
7%endif
Will change the status line to red if running on ‘myhost’, green if running on ‘myotherhost’, or blue if running on another host.
#{ }
#( )
#(pwd)
#{pane_current_path}
Links