Home Terminal Tuts How to adjust the Tmux pane size

How to adjust the Tmux pane size

by Abraham
adjust tmux pane size

T

mux makes it simple to move between several apps on one terminal and to detach and reattach them to another terminal. Because Tmux sessions are persistent, they will still run even if you are disconnected. Tmux is a well-liked multiplexer with many useful settings. You may run many apps simultaneously and switch between them without noticeable lag. If you often move between terminals and struggle to locate the necessary window, think about utilizing a multiplexer.

How to install Tmux

Before we look at the installation process, assemble all the required prerequisites:

Prerequisites:

  1. Linux/Unix-based OS
  2. Command-line access
  3. Sudo /root user access

Once you have the said prerequisites in place, launch your terminal application and execute the following line of code:

sudo apt install tmux
install tmux

Install Tmux

Alternatively, you can install it using the Ubuntu Software Center. Launch the Ubuntu Software Center application, search for tmux and click the ‘Install’ button.

install tmux via software center

Install Tmux via software center

Once Tmux has been installed, you will need to invoke it via the terminal since Tmux does not come with an application associated with it, nor does it come with an icon. Therefore, to launch the installed Tmux application, open your terminal or use the already existing window to execute the following line of code:

tmux
tmux new screen

Tmux new screen

How to use Tmux

Tmux uses notions like sessions, windows, panes, and hotkeys. As a result, newcomers typically find it intimidating at first. However, you’ll feel much more productive after you’ve mastered it. A Tmux session denotes the scope of the job at hand. Windows allows users to do a range of tasks inside a single session.

On the other hand, Panes will allow you to deal with many viewpoints in a single window. Tmux hotkeys, which consist of the Tmux prefix followed by a key, may be used to control all of them. The default prefix is “Ctrl + B.”

How to resize Tmux panes

Resizing panes in Tmux is quite complex when using the default keybinding. However, don’t worry since, in this tutorial guide, I will be illustrating how to configure the tmux.conf file to aid in easily resizing the panes.

By default, when you create a pane/s in Tmux, it splits the window into 50% splits.

pane resizing using arrow keys

Pane resizing

However, the major question is, what do you do when you want some panes to contain more space than others? That is where pane resizing comes in. To resize a pane, you always use the default prefix ‘Ctrl + b’ followed by the colon (:) key. When you invoke these key combinations, it will prompt at the bottom of your screen. To resize the pane, you will need to use the prompt to resize the desired pane.

input command to resize pane

Input command to resize the pane

For example, to resize a pane, you must type in the ‘resize-pane’ command followed by a hyphen (-) and either one of these options (D, U, R, L). These options are down, up, right, and left, respectively. Its work is to resize the pane in the direction provided.

:resize-pane -D 10
resized pane using resize pane command

Resized pane using the resize-pane command

Note: While using the resize-pane command, the resize option triggered will be applied to the last pane you were in.

Below is a syntax that can help you quickly grasp the resizing concept:

:resize-pane -D (Resizes the current pane down by one cell)

:resize-pane -R (Resizes the current pane right by one cell)

:resize-pane -U (Resizes the current pane upward by one cell)

:resize-pane -L (Resizes the current pane left by one cell)

:resize-pane -U 10 (Resizes the current pane upward by ten cells)

:resize-pane -R 10 (Resizes the current pane right by ten cells)

:resize-pane -D 10 (Resizes the current pane down by ten cells)

:resize-pane -L 10 (Resizes the current pane left by ten cells)

If you wish to configure your keybindings, then open the tmux.conf file and append the following lines of code:

bind -n M-H resize-pane -L 2

bind -n M-L resize-pane -R 2

bind -n M-K resize-pane -U 2

bind -n M-J resize-pane -D 2
configure keybindings

Configure keybindings

The above codes will help you use the ‘Usual’ (H, J, K, L) to resize the panes. If you have your own default keys you intend to use, then you can bind them into tmux.conf file. Once you are done, remember to exit the current session and start a new session or execute the reload command to reload the tmux.conf file.

resized panes

Resized panes

Using the mouse mode

This is one of the easiest alternatives to resize panes on Tmux. Using the mouse is much more convenient as it does not require any commands. This method is usually preferred since it provides more control over the pane size than the first method, which involves using the resize-pane command. Open the tmux.conf file and append the following line of code:

set -g mouse on
set mouse mode

Set mouse mode

Once you are done, reload the tmux.conf file by executing the following line of code:

tmux source-file ~/.tmux.conf
reload tmux config file

Reload Tmux config file

Note: It is always vital to reload the tmux.conf file to effect the changes made.

resized panes

Resized panes using mouse mode

Using the Arrow keys plus the default prefix

This is another technique that can be used to resize Tmux panes. You can resize the panes by using the default ‘Prefix’ (Ctrl + b) plus the arrow keys.

For example, to resize a pane to the right, use the default prefix followed by the right arrow key. This applies to all other directions, such as up, down, left, and right.

pane resizing using arrow keys

Pane resizing using arrow keys

That’s how to resize panes on Tmux.

Conclusion

This guide illustrated how to resize Tmux panes on your Linux OS. All the methods provided are effective and have been tested. Therefore, don’t shy away from trying them. If you encounter a challenge, don’t hesitate to let us know via the message board below.

You may also like

Leave a Comment

fl_logo_v3_footer

ENHANCE YOUR LINUX EXPERIENCE.



FOSS Linux is a leading resource for Linux enthusiasts and professionals alike. With a focus on providing the best Linux tutorials, open-source apps, news, and reviews written by team of expert authors. FOSS Linux is the go-to source for all things Linux.

Whether you’re a beginner or an experienced user, FOSS Linux has something for everyone.

Follow Us

Subscribe

©2016-2023 FOSS LINUX

A PART OF VIBRANT LEAF MEDIA COMPANY.

ALL RIGHTS RESERVED.

“Linux” is the registered trademark by Linus Torvalds in the U.S. and other countries.