How to set pane titles with tmuxinator
Asked Answered
X

2

9

How do you set a unique title on each pane in a tmuxinator session?

I'm trying to run multiple panes to show the output from htop being run through ssh to different servers. My configuration looks like:

project_name: Server Monitor
windows:
  - servers:
      layout: tiled
      panes:
        - ssh -t -i mykey.pem user@server1 htop
        - ssh -t -i mykey.pem user@server2 htop
        - ssh -t -i mykey.pem user@server3 htop

When I launch this with tmuxinator local, it runs the commands just fine and I see the output from htop. However, the panes all look the same and the SSH title isn't shown, making it nearly impossible to tell which pane corresponds to which server.

How do I change my configuration so that a unique title is shown on each pane?

This example shows that this feature is supported in the underlying tmux, but I'm not sure how to access this through tmuxinator.

Xylotomous answered 13/12, 2017 at 19:41 Comment(0)
D
10

What you need to do is first enable pane status in your .tmux.conf with the lines:

set -g pane-border-format "#{pane_index} #{pane_title}"
set -g pane-border-status bottom

Then add to your tmuxinator config a printf command that will send the appropriate escape sequence to dynamically set the pane title. You will have 2 commands now per pane, so you need to add another level of indentation with a name.

project_name: Server Monitor
windows:
  - servers:
      layout: tiled
      panes:
        - p1:
          - printf '\033]2;%s\033\\' 'server1'
          - ssh -t -i mykey.pem user@server1 htop
        - p2:
          - printf '\033]2;%s\033\\' 'server2'
          - ssh -t -i mykey.pem user@server2 htop
        - p3:
          - printf '\033]2;%s\033\\' 'server3'
          - ssh -t -i mykey.pem user@server3 htop

You need at least tmux 2.3 to have pane titles shown in the borders.

Deploy answered 17/12, 2017 at 9:36 Comment(1)
Thanks. Unfortunately, I only have access to tmux 2.1.Xylotomous
S
0

For anyone else who comes across this and:

  • Doesn't want to change their layout
  • Has a problem parsing the structure in Meuh's answer (I was getting a undefined method shellescape for #<Array error.

You still need to add these to your .tmux.conf:

set -g pane-border-format "#{pane_index} #{pane_title}"
set -g pane-border-status bottom

You can just add a ; before the ssh command and do this:

name: myBoxes
root: ~/
windows:
- hosts:
    layout: tiled
    panes:
    - printf '\033]2;%s\033\\' 'role_storage_v45 : hostname2.net'; ssh 10.20.30.1
    - printf '\033]2;%s\033\\' 'role_dns_v15 : hostname1.net'; ssh 10.20.30.2
Syncretize answered 16/7, 2019 at 15:16 Comment(2)
Your printf command has no effect on my system. It outputs nothing in my terminal. The set commands also have no effect when I add them to my ~/.tmux.conf, which I don't think tmuxinator uses.Xylotomous
Tmuxinator doesn't use them, but it doesn't matter. Tmux does. You can try putting them in manually by doing <PREFIX> :<CMD> . Then run the printf command in any terminal. Make sure you're on a recent version of tmux.Syncretize

© 2022 - 2024 — McMap. All rights reserved.