How do you hide a tmux pane?

Use the break-pane and join-pane commands. Refer to man tmux for details, options and usage.


Hide Pane 3:

Select pane 3 and enter Prefix-:break-pane -dP.

tmux will send pane 3 to a window in the background (the -d flag) and print some information about it in pane 2 (the -P flag). By default you'll see something like 1:2.0 (meaning: session:window.pane). Hit q to continue working.1

1With some practice you will be able to drop the -P flag since you can predict the session:window.pane triplet: session defaults to the current session and pane defaults to 0 while window will be the next free window identifier.

Get Pane 3 back:

To get pane 3 and the layout back, select pane 2 and issue Prefix-:join-pane -vs 1:2.0 telling tmux to split pane 2 vertically (-v) and to join the (source) pane (-s) with identifier 1:2.0. Optionally, you can drop either the session or the pane identifier. Note also that tmux stores a command line history, conveniently accessible with Prefix-:-Up or Prefix-:-ctrl-p.

You'll probably need some time to get the hang of it, but once you do, you'll surely be able to come up with custom key bindings that are convenient for you.


This question contains some useful information and tricks that might improve your workflow.


An idea: run tmux in tmux.

Original set up:

Pane 1 and pane 2; side by side. Run vim in Pane 1 as normal.

In pane 2, run tmux again and create two panes (one on top of the other this time). Then run vim in pane 2.1 and your CLI in pane 2.2. This should allow you to full screen pane 2.1 with your second instance of Vim resulting in the behaviour you want.


I now this question is almost 5 years old but I just found it because I wanted to do something similar and I came up with the following keybindings thanks to user78291's answer:

bind-key ! break-pane -d -n _hidden_pane
bind-key @ join-pane -s $.1

This way, I can use Prefix! to hide the current pane and Prefix@ to bring it back. The nice part is that I can hide multiple panes this way.

It's far from perfect, but it does the job of hiding panes and bringing them back quite well.

Tags:

Tmux