4

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.

  • Shameless plug: I wrote a script that colors each new tmux session with a new color. – Alexander Rodin May 27 '17 at 8:36
1

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.

| improve this answer | |
1

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)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.