How to Adjust the tmux Pane Size?

tmux is the multiplexer tool used to run multiple terminal windows simultaneously. For the ease of the user, tmux provides the feature of splitting the terminal windows into further windows. All these windows are known as the pane of tmux. We can adjust the tmux pane size upon our configuration. This blog will help Linux users understand the tmux pane’s usage the blog contents are:

Let’s start the blog with the installation of the tmux!

Prerequisite: Install the tmux on Linux

Make sure that the tmux has been installed on the computer, and if it is not installed, then it can be installed on the Ubuntu y executing the command:

$ sudo apt install tmux -y

If you are using other than Ubuntu Linux distribution, then it can be installed with the command:

Fedorasudo dnf install tmux
RHELsudo yum install tmux

After making sure that the tmux has been installed, proceed to the next sections of the blog to adjust the pane size.

Method 1: Split and Resize tmux Pane

To adjust the tmux pane size, launch the tmux with the command:

$ tmux

The tmux terminal has been launched:

We will split the one opened pane of the tmux into two different panes in the ratio of 1:1. To make the pane split vertically first, use the shortcut of the Ctrl+b and then SHIFT+”:

When the screen is split into two equal parts, press the “CTRL+B” and then the semi-colon. After which, we can see the screen like this:

To resize the pane, we should type the phrase “resize-pane”:

Then, we have to mention the options D for down, U for Up, R for right, and L for left. For example, if we want to resize the pane in the downward direction, we will use the D option:

Lastly, use the numeric number, which indicates the cells by which it will be resized. For example, if we want to resize the pane by five cells in the downward direction, we will enter 5 next:

And then press the ENTER key:

The pane has been customized but remember that the last pane in which your cursor is present will always be resized.

Method 2: Adjust Pane Size Using the Mouse Mode

This is the easiest method to resize the pane of tmux without using any shortcut keys. To use this, open the configuration file of the tmux with the nano text editor:

$ nano .tmux.conf

And enter the following line in the file:

set -g mouse on

After closing the file by making the changes reload the file with the source command:

$ tmux source-file ~/.tmux.conf

After this, drag the split lines of the windows to adjust the tmux pane size:

This way, you can change the tmux pane size with the mouse easily.

Method 3: Adjust Pane Size Using Arrow Keys

The last method is to press the “CTRL+B” and then the arrow keys, in which direction you want to adjust the pane:

These are three methods by which the pane of the tmux can be adjusted.

Conclusion

To adjust the tmux pane size, use the mouse keys, the arrow keys with the prefix, or the commands used with the prefix. This blog demonstrates all these methods of adjusting the pane size in detail. The easiest approach is the prefix with the arrow key or the mouse method.