On my local machine I've got 3 node.js instances running simultaneously. Each has it's own pane in a tmux window called "servers". The problem is that it's not that easy to figure out which node is running in which pane, 'cause their logs are similar.
What I need is a title for every pane. As I got, tmux itself doesn't have the feature: it has only titles for windows and not for panes. Launching a separate tmux session inside every pane for every node.js instance looks like an overkill.
So is there some small program that launches a command, wrapping its output with a specified status bar?
Thanks in advance
Yes there is such a command:
tmux
. Give your session a name and it will be displayed in an inner status bar:This functionality has been added to tmux git in this commit. It is not in version 2.2, but it looks like it will be in 2.3.
To enable it:
or if you prefer:
To set a custom text as your pane border status line you can make use of
pane-border-format
, e.g. like so:tmux does support per-pane titles, but it does not provide a per-pane location to display these titles.
You can set a pane’s title with the escape sequence ESC
]2;
… ESC\
(e.g. see the section called Names and Titles in the tmux manpage). You could do this from the shell like this:Each pane’s title defaults to the system’s hostname. By default the active pane’s title is displayed on the right side of the tmux status line (the default global value of the session variable
status-right
is"#22T" %H:%M %d-%b-%y
, which shows 22 characters of the pane’s title, the time, and the date).So, as long as you are satisfied with being able to see the active pane’s title (i.e. willing to switch panes to see the title of an inactive pane), you can get by with the default functionality. Just send the appropriate title-setting escape sequence before starting the main command for each pane.
If you absolutely need a dedicated line to display some per-pane information, then nested tmux sessions may not be as much (unnecessary) “overkill” as you might first think.
In the general case, to provide an inviolate status line on some given terminal, you will need a full terminal (re)emulator that sits between the original terminal and a new terminal (one with one fewer lines). Such (re)emulation is needed to translate control sequences sent to the inner terminal and translate them for the original terminal. For example, to maintain a status line at the bottom of the outer terminal, the command
sent to the inner terminal must be become
when translated for and sent to the outer terminal. Likewise, an LF sent to the inner terminal must become
in the outer terminal.
Programs like tmux and screen are just such terminal re-emulators. Sure, there is a lot of other functionality wrapped around the terminal emulator, but you would need a large chunk of terminal emulation code just to provide a reliable status line.
There is, however, a light-weight solution as long as
Like many terminal emulators, tmux supports a “set scrolling region” terminal control command in its panes. You could use this command to limit the scrolling region to the top (or bottom) N-1 lines of the terminal and write some sort of instance-identifying text into the non-scrolling line.
The restrictions (no cursor movement commands allowed, no resizing) are required because the program that is generating the output (e.g. a Node.js instance) has no idea that scrolling has been limited to a particular region. If the output-generating program happened to move the cursor outside of the scrolling region, then the output might become garbled. Likewise, the terminal emulator probably automatically resets the scrolling region when the terminal is resized (so the “non-scrolling line” will probably end up scrolling away).
I wrote a script that uses
tput
to generate the appropriate control sequences, write into the non-scrolling line, and run a program after moving the cursor into the scrolling region:You might use it like this:
The script should also work outside of tmux as long as the terminal supports and publishes its
csr
andcup
terminfo capabilities.I am using tmux version 2.3, I think border style is not supported in previous versions. this is what worked for me:
For each pane set the title:
Then:
This is not helpful in the short-term, but there is a feature request for per-pane titles in tmux: http://sourceforge.net/tracker/?func=detail&aid=3495916&group_id=200378&atid=973265#
In the meantime, as others mentioned, nesting tmux works decently.
I'm working on the pane status bar for tmux - ticket. My development branch can be found here on github: https://github.com/jonathanslenders/tmux
Right now, this already adds a working rename-pane "title" command. There are still some bugs, and the API will improve. The idea is to create a status bar per pane, which can have some formatting, like the session status bar. Like the rest of tmux, everything should become scriptable, and customizable. When finished and stable, it will probably be included in the official tmux.