tmux setup with different status bars for each project automated using tmuxp.
I often have multiple tmux sessions running at the same time in separate
windows, corresponding to different projects – wouldn’t it be nice to have some
visual indication to easily tell one session from the other?
In this note we describe a setup that automatically bootstraps the tmux session
for different projects and configure it so that different colors are used for the status
bar, depending on the project.
I tested this setup on Debian Linux and Mac with tmux 3.0.
Make sure to have the
following option in the .tmux.conf file to ensure the 8-bit color palette is
set-option -g default-terminal "screen-256color"
tmux automation using tmuxp
is a tool for automating tmux
setups. It allows you to describe the desired session state in a YAML file,
which can then be loaded to construct the tmux session. For example, a minimal
session setup I use when working on this blog looks like so:
- cd ~/projects/blog
- window_name: shell
- focus: 'true'
- shell_command: hugo server -D
This file can be then loaded via tmuxp load <path>, resulting in a single
window, two-pane tmux session, with hugo server -D running in one of the
panes. Before bootstrapping the session, tmuxp will run cd ~/projects/blog, so
the tmuxp load command can be issued from any working directory. So far so
Setting the colors for the status bar
We can experiment with different status bar colors while in a tmux session:
This seems to yield different results depending on the version of tmux:
on tmux 2.8, I see the config below working reliably and being equivalent to the config above, on both Linux and MacOS
⚠️ on tmux 3.0, I see the config below change the status bar globally for all tmux sessions when a session is loaded, on both Linux and MacOS
I thought this may be due to a backward-incompatible change in tmux that was not
handled in tmuxp, but tmux
between 2.8 and 3.0
don’t seem to note anything relevant, so the mystery persists – in the meantime,
using shell_command_before as noted above is a good workaround.
The Tao of tmux
is a comprehensive introduction to tmux by Tony Narlock
, the author of tmuxp. The book is available to read online for free.