I set up 2 tmux sessions to work on different parts of a project (switching back and forth frequently). As their layout are pretty similar, I would like to set different status-bar color to help me quickly identify the current session.

After reading the manual, it seems that

set -t session_name status-bg blue

would be what I am looking for. But running that command changes both session status-bar color. Is it possible to achieve a per-session styling in tmux ?

I also tried naming the window and pass its name to -t but was no more successful.

Can't find that information. Also, I might not get tmux session use-case right.

  • 1
    Shameless plug: I wrote a script that colors each new tmux session with a new color. Commented May 27, 2017 at 8:36

3 Answers 3


You need to do the following in newer versions of tmux:

set -t session_name status-style bg=blue

This worked for me in tmux 3.0a. Also, if you subsequently want to change another attribute, say the color of the text in the status bar, you need to use the -a (append) option, as tmux will otherwise overwrite your previous setting (in this case the background color) with its default choice for the new setting (in this case, the text color). So it will look as follows:

set -a -t session_name status-style fg=green

You can find more information here http://man7.org/linux/man-pages/man1/tmux.1.html (search for setw and you'll get to the options section)


You can try playing with hooks. Here is an example that I did for two sessions,

set-hook -g after-new-session 'if -F "#{==:#{session_name},emacs}" "source ~/.tmux/.tmux.conf.emacs" "source ~/.tmux/.tmux.conf.amos"'
set-hook -g after-new-window 'if -F "#{==:#{session_name},emacs}" "source ~/.tmux/.tmux.conf.emacs" "source ~/.tmux/.tmux.conf.amos"'

Be aware that after-new-window hook is necessary.

You can find my whole setup in github.


I have wanted to do this for a long time and found all the proposed solutions convoluted and confusing, but I finally figured out a way I'm happy with to do this.

The main thing that confused me for a long time was that the tmux config is only run when the server is started by default - it isn't run when a new session is started. Since session styling should be run when the session is created, you can have a script to control that. In my case I do something like this in tmux.conf:

set-hook -g session-created "send-keys tmux-session-style Enter"

And then the script tmux-session-style can do whatever you want, and can read tmux variables for the current session from the environment. Here I customize it based on session name and working directory.

# Customize based on session name or other details
set -eou pipefail

# get the name of the current session
name="$(tmux display-message -p '#S')"

if [ "$name" == "notes" ]; then
  tmux set status-bg colour3
elif [ "$name" == "blarg" ]; then
  tmux set status-bg colour10
elif [[ "$PWD/" = /home/user/work/* ]]; then
  tmux set status-bg colour161

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .