19

Is it possible to have the same pane appear in two different windows of a single tmux session?

I typically have a single horizontal split in my main window with vim in the top pane (about 80-90% of the terminal height), and a command line in the bottom pane where I run the program I'm working on. Because the bottom window is so small, I often can't see error output, and using tmux's keyboard shortcuts to scroll back is getting tiresome. I'd like to have my second window attach to the same pane so that if I need to see more of my error output, I can just quickly switch to the second window without needing to deal with scrollback. Is this possible?

(I guess one fallback would be to use something like tee to write stdout to a log file and tail that in my second window. I'm hoping that's not necessary though)

5 Answers5

12

I'm afraid this is one of the things you can't do with tmux (I would expect the problems with one pane being displayed in several spaces of different sizes to be the main reason). However, there are several ways you can work around that - all based on binding certain actions to some key combinations. Since a lot depends on the layout you are using, having just a simple layout with two panes you are mentioning is making your life much easier

  1. rotate-window - it will just swap the panes, thus giving you 80%-90% for command output (and the small window for ViM).

  2. break-pane vs. join-pane -v -p <preview_percentage> -t !

  3. pipe-pane with command being unbuffered redirection to a named pipe (i.e. a file system node created with mkfifo) - then use tail -f that named pipe in the other pane.

  4. pipe the output to less, which also has the follow mode that tail has (at least the GNU one).

  5. resize-pane -Z on the smaller panel will zoom it on full terminal. Subsequent un-zoom will keep it active so a little bit trickery is needed to make it work comfortably.

peterph
  • 30,838
  • 2
    BTW - "I would expect the problems with one pane being displayed in several spaces of different sizes to be the main reason" That might be a factor in the complexity of implementing it, but tmux does support the same thing at window level, via grouped sessions http://unix.stackexchange.com/questions/24274/attach-to-different-windows-in-session. It simply adds padding below to the smaller window. Theoretically pane mirroring could be done the same way. – mahemoff Feb 07 '14 at 11:20
  • Hm... you're right, that could be a way to go about it. – peterph Feb 07 '14 at 19:46
9

By default, you can toggle a pane's "zoom state" by pressing Prefix and z (the default prefix is Ctrl+B).

This will make the current pane (your command line pane, for example) occupy the whole window. Press Prefix and z again to "unzoom" the pane.

Kusalananda
  • 333,661
2

You can use a script to output your pseudo-session to a file and then tail that file in a second window.

In your working pane.

script -f tailme.out

And in your viewing pane.

tail -f tailme.out
Thomas
  • 6,362
2

I agree with others that for your case Prefix + z would be the most direct solution, but for the general question of mirroring a pane there's a bit of a hack that could work - nesting a screen session inside tmux.

Install gnu screen, then start it up for the pane you want to mirror. Then screen -x to attach in other panes.

You could also nest another tmux session in the pane if you wanted to, but tmux sessions should be nested with care.

Matthew
  • 1,061
1

You can't do it with one tmux. But you can do it with two tmux session.

  1. start another tmux session in your tmux:
unset TMUX
tmux new-session -s shared
tmux set-option prefix C-o; # optional to change prefix key
  1. In a pane in another window, attach to the shared session:
unset TMUX
tmux attach-session -t shared

Now commands and output are all synchronized!

drdr.xp
  • 11