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:
- Linux/Unix-based OS
- Command-line access
- 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
Alternatively, you can install it using the Ubuntu Software Center. Launch the Ubuntu Software Center application, search for tmux and click the ‘Install’ button.
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:
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.
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.
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
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
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.
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
Once you are done, reload the tmux.conf file by executing the following line of code:
tmux source-file ~/.tmux.conf
Note: It is always vital to reload the tmux.conf file to effect the changes made.
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.
That’s how to resize panes on Tmux.
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.