vinayak
Posted on December 3, 2023
As Linux users, most of our time is spent working in the terminal window, and it's no surprise that we often require multiple terminals for multitasking. Thus the invention of multiplexers. Which significantly enhanced the functionality of the terminal, leading to increased productivity.
There are multiple terminal multiplexers but one of the most popular is TMux. In this article, we will deep dive into TMux's key features.
TMux is a command-line utility for Unix-like operating systems, including Linux. It enables users to create and manage multiple terminal sessions within a single window. In simple words, it's an alternative to using the graphical tabs and lets you organize your terminal into panes and windows.
Installing TMux in Linux
we can install tmux with our package manager (in the terminal)
- Debian/Ubuntu:
sudo apt-get install tmux
- Redhat
sudo yum install tmux
- Fedora
sudo dnf -y install tmux
Starting Tmux inside Terminal
After installing tmux, you can simply start it by typing the command tmux
in your terminal. This initiates a new tmux session.
tmux
Panes in Tmux
Similar to Vim, tmux also has a leader key that is used to trigger various commands within tmux., by default its ctrl + b
- To split the window vertically, we can use
ctrl + b %
Similarly to closing a window, we can use
Ctrl + b x
, and to Navigate between the panes we can useCtrl + b <arrow-key>
For changing the panel layout leader key with space can be used
Ctrl + b space
To resize a panel in tmux, we can use the
resize-pane
command. Press the leader key to enter command mode. Similar to Vim, we can then enter the resize command to adjust the size of the pane using the:
symbol.
Ctrl + b : resize-pane -L 10
Ctrl + b : resize-pane -R 10
Ctrl + b : resize-pane -D 10
Ctrl + b : resize-pane -U 10
Windows in Tmux
windows in tmux is a little different from Panes, while panes divide the terminal, on the other hand, windows can be used as a new tab. Where each window can contain one or more panes.
To create a new window, press the leader key and
c
that isctrl + b c
To Navigate to the next window,
Ctrl + b n
can be usedTo Navigate to the previous window,
ctrl + b p
can be used&
is used to close a window,ctrl + b &
Renaming windows
Now that we have multiple windows within our terminal emulator, it's a good idea to rename it to streamline our workflow. For Renaming we can use ,
with ctrl + b
List Windows
We can see a list of windows by using Ctrl-b
followed by w
. This provides a visual overview, where we can navigate to a window using the arrow keys.
Sessions in Tmux
Sessions in Tmux provide an easy way to group tasks or activities in a single terminal multiplexer in one or more instances.
Creating a Session
As soon as we open tmux in the terminal, a default session is created. However, we can also create a new session with a different name.
For naming a session, we can use the new-session
command.
tmux new-session -s session_name
Detaching from a Session
One session is created, and once inside, we can detach it using the combination of d
after the leader key. ctrl + b d
Attaching to a Session
After detaching, we can log back in by attaching it using the attach-session
command.
tmux attach-session -t session_name
Posted on December 3, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.