1

I have a tmux window where I show 3 panes:

  1. remote_development (yeah I know it's weird)
  2. quality_assurance
  3. production

I would like to format the pane titles like so:

  1. dark green background with white text
  2. yellow background with black text
  3. dark red background with white text

I can change the colors, but no matter what I've tried, it applies to all pane borders & titles. Is there any way in any current versions of tmux to set the color only of a specific pane border & title?

For example, each of these lines sets the pane border format

tmux set pane-border-format '#[fg=brightwhite#, bg=darkgreen] #W [#{pane_index}] → #{pane_title} '
tmux set pane-border-format '#[fg=black#, bg=yellow] #W [#{pane_index}] → #{pane_title} '
tmux set pane-border-format '#[fg=white#,bg=darkred] #W [#{pane_index}] → #{pane_title} '

but each line changes all of them. Using -t doesn't seem to make any difference.

1 Answer 1

1

Ouch, yes, that's a pane (pun intended). pane-border-format and pane-border-style are server options, not pane options.

As such, you have to come up with one style or format that handles all your use cases. That starts to become a nested mess of conditionals pretty quickly. With three panes, it's workable, but it ain't pretty.

I'm going to format this as a multiline to start with for readability. You'll want to remove the extra whitespace when using it in practice since the whitespace does get displayed:

tmux set pane-border-format "
#{?#{==:#{pane_title},remote_development},
    #[fg=white bg=green],
    #{?#{==:#{pane_title},quality_assurance},
        #[fg=black bg=yellow],
        #{?#{==:#{pane_title},production},
            #[fg=white bg=red],
            #[default]
        }
    }
}
#{pane_index} #{pane_title}
"

It's basically a nested conditional that matches the pane title against the ones you list, and then sets the colors you mentioned before displaying the index and title. I took out the normal "reverse" indicator for the active pane since it would have (I believe) have required an entire new nesting level, but you can add some other indicator if you want.

1
  • Absolutely brilliant!
    – iconoclast
    Mar 22 at 17:51

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.