Why to learn Tmux?
So, the main and important question to ask is: why use Tmux? If I can do all my work from a single terminal, then why would I even touch it?
Because Tmux is a terminal multiplexer — it allows you to create several “pseudo-terminals” from a single terminal. This is very useful for running multiple programs with a single connection, such as when you’re remotely connecting to a machine using Secure Shell (SSH).
Installing Tmux 🚀
The first step is to install it on your machine, because without it, you obviously can’t use it.
ForLinux
Debian Based
Install it with apt package manager.
sudo apt install tmux
Arch Linux
Install it with pacman package manager simply.
pacman -S tmux
For Fedora
Install it with dnf.
dnf install tmux
For RHEL or CentOS
Install it with yum.
yum install tmux
For MacOs
Just use the homebrew package manager to install it. (recommended way)
brew install tmux
For Windows
Unfortunately, there’s no official package available for Windows. However, you can install it using WSL (Windows Subsystem for Linux) and follow the Linux guide.
Basic Concepts of Tmux 🛰️
Before really starting to use tmux one must understand the basic things that are important to control tmux.
Some Keywords to memorize
| Keyword | Description / Use Case |
|---|---|
| Session | A Tmux session is like a workspace. You can create multiple sessions and switch between them. Useful for managing different projects or tasks. |
| Window | Each session can have multiple windows (like tabs). A window typically runs one shell or program. |
| Pane | A window can be split into multiple panes. Each pane is like a mini-terminal within the window. Great for multitasking or monitoring multiple processes. |
| Status Bar | The status bar is the line at the bottom of the Tmux interface. It shows info like session name, windows, time, and can be customized with plugins or scripts. |
Let’s Use Tmux
After successfully installing tmux open your terminal and type
tmux
- This will start a new tmux session without a special name.
To start a tmux session with a name of your choice you can use the -s flag.
tmux new -s desired_name
This will open a session in your terminal. You can see your session name at the bottom of your session. This bottom bar is known as the Status Bar.
Like in the photo above, you’ll be able to see something similar.
Key Bindings to remember
For controlling panes
| Key Binding | Use Case |
|---|---|
Ctrl + B + % | To create a pane horizotally within the window of the session. |
Ctrl + B + " | To create a pane vertically within the window of the session. |
Ctrl + B + ⬆️⬅️➡️⬇️ | To navigate among the panes. |
