Getting Started with tmux — From Installation to Real-World Setup (Ubuntu/Kubuntu)
-
Jason Yang - 20 Apr, 2026
- Updated 20 Apr, 2026
- Views —
Why Use tmux?
If you’ve spent any time in the terminal, you’ve probably run into situations like these:
- You’re running a long build or training script, and you accidentally close the terminal → start over from scratch
- You’re working on a remote server via SSH and the network drops → all your work is gone
- You’re juggling multiple projects at once, and window management becomes a mess
The tool that solves all of these problems is tmux (terminal multiplexer).
Core Advantages of tmux
1. Session Persistence
This is tmux’s biggest advantage.
Close the terminal → tmux session stays alive
Reconnect later → pick up right where you left off
Even if your SSH connection drops or you close your laptop lid, the processes inside your session keep running.
tmux attach # reconnect after disconnection
2. Manage Multiple Named Sessions
Session 1: backend
Session 2: frontend
Session 3: docs-work
Unlike Ghostty/Konsole tabs, tmux lets you organize sessions by name and reattach to them later even after closing the terminal.
3. Keyboard-Driven Window Splitting and Navigation
You can split and move between panes without touching the mouse, keeping your hands on the keyboard.
4. Consistent Experience Across Any Terminal Emulator
Ghostty, Konsole, Alacritty, an SSH session — your tmux config works identically everywhere. Switch terminals, and your working environment stays the same.
Why tmux If You Already Have Ghostty (or Konsole)?
Modern terminal emulators have built-in window splitting. So why still use tmux?
| Terminal Only | Terminal + tmux | |
|---|---|---|
| Session persistence | No | Yes |
| SSH reconnection | No | Yes |
| Named session management | No | Yes |
| GPU-accelerated rendering | Yes (Ghostty) | Preserved |
In other words, tmux is not a replacement for your terminal — it’s a complement. Ghostty’s fast rendering + tmux’s session management is the ideal combo.
Installing tmux on Ubuntu/Kubuntu
sudo apt install tmux
That’s it.
My tmux Configuration (~/.tmux.conf)
Create a .tmux.conf file in your home directory.
# Enable mouse support
set -g mouse on
# 256 colors + true color (24-bit)
set -g default-terminal "tmux-256color"
set -ga terminal-overrides ",*256col*:Tc"
# Change prefix key to Ctrl+a (default is Ctrl+b)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
# Start window numbering at 1
set -g base-index 1
setw -g pane-base-index 1
# Split windows (keep current path)
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
# Pane navigation (vim-style)
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Status bar
set -g status-position bottom
set -g status-bg colour234
set -g status-fg colour137
set -g status-left ''
set -g status-right '#[fg=colour233,bg=colour241] %Y-%m-%d #[fg=colour233,bg=colour245] %H:%M '
# Scroll history
set -g history-limit 10000
# Remove ESC delay (for vim)
set -sg escape-time 0
# Copy mode - vim style
setw -g mode-keys vi
bind [ copy-mode
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi V send -X select-line
bind -T copy-mode-vi C-v send -X rectangle-toggle
bind -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -selection clipboard -in"
bind -T copy-mode-vi h send -X cursor-left
bind -T copy-mode-vi j send -X cursor-down
bind -T copy-mode-vi k send -X cursor-up
bind -T copy-mode-vi l send -X cursor-right
bind -T copy-mode-vi q send -X cancel
# Mouse drag → auto copy to system clipboard
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-pipe-and-cancel "xclip -selection clipboard -in"
Key Config Explained
1. Prefix key changed to Ctrl+a
The default Ctrl+b requires more finger movement. Ctrl+a is much easier to reach. (Note: since Ctrl+a is bash’s “move to start of line” shortcut, you’ll need to press prefix twice to trigger the original behavior inside bash.)
2. Window split keys | and -
Intuitive and visually meaningful (| vertical line = left/right split, - horizontal line = top/bottom split).
3. vim-style pane navigation (h/j/k/l)
If you’re a vim user, you already have muscle memory for these keys.
4. Current path preserved on split
The -c "#{pane_current_path}" option makes new panes start in the same directory as the current one.
5. Mouse support
Scrolling, pane selection, and text drag-selection all work with the mouse.
Why Do You Need xclip?
xclip keeps coming up in the config — let’s see why it matters.
The Problem: tmux Clipboard and System Clipboard Are Separate
Analogy
[tmux buffer] [System clipboard]
copied text where Ctrl+C/V operates
↕
xclip acts as the bridge
- Without xclip: copy inside tmux → can only paste inside tmux (
Ctrl+a ]) - With xclip: copy inside tmux → paste anywhere (browser, Slack, other apps) with
Ctrl+V
Simply put, xclip is the bridge between tmux and all your other apps for copy/paste.
Installation
sudo apt install xclip
Once installed, the config above just works. Drag-select with the mouse, and the text automatically lands in your system clipboard, ready to paste anywhere with Ctrl+V.
Applying the Config
If tmux is already running:
tmux source-file ~/.tmux.conf
Or inside tmux:
Ctrl+a :source-file ~/.tmux.conf
Basic Usage
Session Management
| Command | Description |
|---|---|
tmux | Start a new session |
tmux new -s name | Start a named session |
tmux ls | List sessions |
tmux attach | Reattach to the last session |
tmux attach -t name | Reattach to a specific session |
Ctrl+a d | Detach from session |
Ctrl+a :kill-session | Kill the session |
Window Management
| Shortcut | Description |
|---|---|
Ctrl+a c | Create new window |
Ctrl+a n | Next window |
Ctrl+a p | Previous window |
Ctrl+a 1~9 | Jump to window N |
Ctrl+a , | Rename window |
Ctrl+a & | Close window |
Pane Management
| Shortcut | Description |
|---|---|
| `Ctrl+a | ` |
Ctrl+a - | Split top/bottom |
Ctrl+a h/j/k/l | Move between panes |
Ctrl+a x | Close current pane |
Ctrl+a z | Toggle fullscreen for current pane |
Copy Mode (vim-style)
| Shortcut | Description |
|---|---|
Ctrl+a [ | Enter copy mode |
v | Start block selection |
V | Line selection |
Ctrl+v | Rectangle selection |
h/j/k/l | Move cursor |
y | Copy + send to system clipboard (thanks to xclip) |
q | Exit copy mode |
Ctrl+a ] | Paste from tmux buffer |
Mouse Usage
- Drag to select text → automatically copied to system clipboard
- Scroll wheel to scroll through history
- Drag pane borders to resize
- Click a pane to focus it
Real-World Workflow Example
Create project-based sessions and start working:
# Start for the first time
tmux new -s backend
# Need to close the terminal mid-work
Ctrl+a d # detach
# Come back later and resume
tmux attach -t backend
Run a different project in parallel:
tmux new -s blog
tmux ls # list sessions
Summary
Why use tmux
- Session persistence: work survives closed terminals and dropped SSH connections
- Named session management: easy to jump between multiple projects
- Keyboard-driven window splits: boosts productivity
Strengths of the Ghostty + tmux combo
- Ghostty’s GPU-accelerated rendering + tmux’s session management
- Consistent working environment across any terminal
Why install xclip alongside
- Bridges tmux buffer and system clipboard
- Lets you copy/paste freely between tmux and other apps (browsers, editors, etc.)
The shortcuts may look overwhelming at first, but you’ll have them memorized after a single day of use. Especially if you frequently work on servers via SSH or run long tasks like Claude Code, tmux becomes less of a choice and more of a necessity.