2026-03-09

If you’ve ever lost what you were doing in the terminal because you accidentally closed a tab, or found yourself frantically switching between multiple windows while running a server, watching logs, and editing code at the same time, tmux is going to change your life.
tmux is a terminal multiplexer. In simple terms: it lets you create, split, and manage multiple terminal sessions within a single window. But the real superpower is that those sessions persist even when you close the terminal or lose your SSH connection. Everything keeps running in the background, waiting for you to come back.
Before jumping into the installation, it’s worth understanding the problems tmux solves:
If you use the terminal frequently, tmux is one of those tools that, once you learn it, you’ll wonder how you ever lived without it.
tmux works with three main layers:
┌─────────────────────────────────────────────┐
│ Session │
│ ┌───────────────────────────────────────┐ │
│ │ Window 1 │ │
│ │ ┌──────────────┐ ┌────────────────┐ │ │
│ │ │ Pane 1 │ │ Pane 2 │ │ │
│ │ │ │ │ │ │ │
│ │ │ │ │ │ │ │
│ │ └──────────────┘ └────────────────┘ │ │
│ └───────────────────────────────────────┘ │
│ ┌───────────────────────────────────────┐ │
│ │ Window 2 │ │
│ └───────────────────────────────────────┘ │
└─────────────────────────────────────────────┘
Think of it this way: sessions are your projects, windows are the screens of the project, and panes are the divisions within each screen.
If you use Homebrew (and you should), the installation is straightforward:
brew install tmux
sudo apt update && sudo apt install tmux -y
sudo dnf install tmux
If you set up WSL following our previous guide, just open the Ubuntu terminal and run:
sudo apt update && sudo apt install tmux -y
tmux -V
You should see something like tmux 3.5a.
To start tmux, simply run:
tmux
Done. You’re inside a tmux session. Notice the green (or colored) bar at the bottom of the screen: that’s the tmux status bar, showing information like the session name and open windows.
But the ideal is to always create named sessions to make organization easier:
tmux new -s my-project
This creates a session called my-project. Much easier to identify when you have multiple sessions running.
Every interaction with tmux starts with a prefix. By default, it’s Ctrl + b. You press the prefix, release it, then press the command key.
For example, to split the screen vertically:
Ctrl + b%It feels weird at first, but it quickly becomes instinct.
Here’s the quick reference for the commands you’ll use daily. They all start with the prefix Ctrl + b:
| Shortcut | Action |
|---|---|
tmux new -s name | Creates a new named session |
tmux ls | Lists all active sessions |
tmux attach -t name | Reconnects to an existing session |
tmux kill-session -t name | Terminates a session |
Ctrl + b → d | Detaches from the session (it keeps running) |
Ctrl + b → s | Lists sessions and lets you switch between them |
Ctrl + b → $ | Renames the current session |
| Shortcut | Action |
|---|---|
Ctrl + b → c | Creates a new window |
Ctrl + b → n | Goes to the next window |
Ctrl + b → p | Goes to the previous window |
Ctrl + b → 0-9 | Goes to a window by number |
Ctrl + b → , | Renames the current window |
Ctrl + b → & | Closes the current window |
| Shortcut | Action |
|---|---|
Ctrl + b → % | Splits vertically (side by side) |
Ctrl + b → " | Splits horizontally (one on top of the other) |
Ctrl + b → arrow | Moves focus between panes |
Ctrl + b → z | Zoom: maximizes/restores the current pane |
Ctrl + b → x | Closes the current pane |
Ctrl + b → { | Moves the pane to the left |
Ctrl + b → } | Moves the pane to the right |
Ctrl + b → space | Toggles between pane layouts |
| Shortcut | Action |
|---|---|
Ctrl + b → [ | Enters scroll/copy mode (exit with q) |
Ctrl + b → t | Shows a clock (yes, it’s useless, but fun) |
Ctrl + b → ? | Lists all available shortcuts |
Let’s set up a real scenario. Say you’re working on a web project and you want:
# Create a session for the project
tmux new -s webapp
# Now you're in the first pane; use it to edit code
# Split vertically (creates pane to the right)
# Ctrl + b, %
# In the right pane, run the server
npm run dev
# Split the right pane horizontally
# Ctrl + b, "
# In the bottom-right pane, use it for git
git status
The visual result looks like this:
┌──────────────────────┬──────────────────┐
│ │ npm run dev │
│ editor / code │ (server) │
│ ├──────────────────┤
│ │ git status │
│ │ (git) │
└──────────────────────┴──────────────────┘
To navigate between panes, use Ctrl + b followed by the arrow keys. To temporarily maximize a pane (zoom), use Ctrl + b → z. Press again to restore.
This is the feature that makes tmux worth it. Imagine you’re running a long build or monitoring logs:
# Detach from the session (everything keeps running)
# Ctrl + b, d
# Leave, close the terminal, go to sleep...
# The next day, list the sessions
tmux ls
# Reconnect
tmux attach -t webapp
Everything is exactly as you left it. Server running, logs flowing, code open. This is especially useful when you work on remote servers via SSH.
The configuration file lives at ~/.tmux.conf. If it doesn’t exist, just create it. Here are some settings that will significantly improve your experience:
# Change the prefix from Ctrl+b to Ctrl+a (more comfortable)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Enable mouse (scroll, click on panes, resize)
set -g mouse on
# Split panes with | and - (more intuitive than % and ")
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# Start counting windows and panes from 1 (instead of 0)
set -g base-index 1
setw -g pane-base-index 1
# Renumber windows when one is closed
set -g renumber-windows on
# Increase scroll history
set -g history-limit 10000
# Reduce escape delay (important for Vim/Neovim)
set -sg escape-time 10
# Reload config with prefix + r
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
After creating or editing the file, reload the configuration:
tmux source-file ~/.tmux.conf
Or, if you added the shortcut above, just press Ctrl + a → r.
Default tmux is functional, but not exactly pretty. Catppuccin and Dracula are two popular themes that transform its appearance.
An even more practical option is TPM (Tmux Plugin Manager), which makes installing plugins and themes easy:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
Add the following to the end of your ~/.tmux.conf:
# Plugin list
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'catppuccin/tmux'
# Initialize TPM (keep this line at the end of the file)
run '~/.tmux/plugins/tpm/tpm'
Inside tmux, press Ctrl + a → I (capital letter I) to install the plugins.
If you use Claude Code or Codex CLI, tmux is the perfect companion. A productive layout:
┌──────────────────────┬──────────────────┐
│ │ │
│ Claude Code / │ server / │
│ Codex CLI │ build │
│ │ │
│ ├──────────────────┤
│ │ │
│ │ git / tests │
│ │ │
└──────────────────────┴──────────────────┘
The AI agent works in the left pane while you monitor the server and run tests in the right panes. No need to switch between tabs.
Tired of building the layout manually every time? Create a script. Save it as ~/dev-tmux.sh:
#!/bin/bash
SESSION="dev"
# If the session already exists, just reconnect
tmux has-session -t $SESSION 2>/dev/null
if [ $? -eq 0 ]; then
tmux attach -t $SESSION
exit 0
fi
# Create the session with the first window
tmux new-session -d -s $SESSION -n "code"
# Split: right pane for the server
tmux split-window -h -t $SESSION:1
# Split the right pane: git below
tmux split-window -v -t $SESSION:1.2
# Focus on the main pane (left)
tmux select-pane -t $SESSION:1.1
# Attach to the session
tmux attach -t $SESSION
Make it executable and run:
chmod +x ~/dev-tmux.sh
~/dev-tmux.sh
Every time you run this script, it will create (or reconnect to) a session with your layout ready to go.
| Command | What it does |
|---|---|
tmux new -s name | Creates a named session |
tmux ls | Lists sessions |
tmux attach -t name | Reconnects to a session |
tmux kill-session -t name | Terminates a session |
Ctrl+b d | Detaches from the session |
Ctrl+b c | New window |
Ctrl+b % | Splits vertically |
Ctrl+b " | Splits horizontally |
Ctrl+b arrow | Navigates between panes |
Ctrl+b z | Zooms into the pane |
Ctrl+b [ | Scroll mode |
Ctrl+b ? | Help |
It’s worth mentioning that there are other tools that solve similar problems:
Now that you have tmux in your arsenal:
~/.tmux.conf with the options that make sense for youtmux is one of those tools that rewards the investment. It may feel verbose at first, but after a week of use, you won’t want to go back.
Liked it? Send me a shout on twitter @lauralesteves