Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set pane titles with tmuxinator

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.

like image 708
Cerin Avatar asked Dec 13 '17 19:12

Cerin


People also ask

How do you name panes?

Panes are automatically named with their index, machine name and current command. To change the machine name you can run <C-b>R which will prompt you to enter a new name. *Pane renaming only works when you are in a shell.

How do you split windows in Tmux?

ctrl + b + % to make a vertical split. ctrl + b + " to make a Horizontal split. ctrl + b + left arrow to move to the left pane. ctrl + b + " to make a Horizontal split.


1 Answers

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.

like image 54
meuh Avatar answered Nov 19 '22 14:11

meuh