tmux — Terminal Multiplexer for Sessions, Windows, Panes
tmux is a terminal multiplexer that lets you switch between several programs in one terminal, detach them, and reattach them to a different terminal. Essential for SSH workflows, long-running processes, and pair programming.
What it is
tmux is a terminal multiplexer that lets you create multiple terminal sessions within a single terminal window, split the screen into panes, and detach/reattach sessions. When you disconnect from SSH, tmux keeps your programs running. Reattach later and everything is exactly where you left it.
This tool is essential for developers working over SSH, running long processes, or managing multiple terminal workflows simultaneously. It is installed on most Linux servers and available on macOS.
How it saves time or tokens
tmux eliminates the fear of losing work when an SSH connection drops. Long-running builds, database migrations, and server monitoring continue in detached sessions. The ability to split panes lets you monitor logs while editing code without switching windows. For AI-assisted terminal workflows, tmux sessions provide persistent context that survives disconnections.
How to use
- Install tmux.
- Start a new session.
- Use key bindings to manage panes and windows.
- Detach and reattach as needed.
# Install tmux
brew install tmux # macOS
sudo apt install tmux # Ubuntu/Debian
# Start a new named session
tmux new -s myproject
# Detach from session (inside tmux)
# Press Ctrl+b, then d
# List sessions
tmux ls
# Reattach to session
tmux attach -t myproject
# Kill a session
tmux kill-session -t myproject
Example
Common tmux key bindings (after Ctrl+b prefix):
Ctrl+b % Split pane vertically
Ctrl+b " Split pane horizontally
Ctrl+b o Switch to next pane
Ctrl+b x Close current pane
Ctrl+b c Create new window
Ctrl+b n Next window
Ctrl+b p Previous window
Ctrl+b d Detach from session
Ctrl+b [ Enter scroll/copy mode
Ctrl+b z Zoom current pane (toggle)
A .tmux.conf customization:
# Enable mouse support
set -g mouse on
# Start windows and panes at 1, not 0
set -g base-index 1
setw -g pane-base-index 1
# Use vi keys in copy mode
setw -g mode-keys vi
# Increase scrollback buffer
set -g history-limit 50000
Related on TokRepo
- Automation tools — Terminal productivity tools
- DevOps tools — Server management tools
Common pitfalls
- The default prefix key (Ctrl+b) is awkward. Many users remap it to Ctrl+a in .tmux.conf.
- Scrolling inside tmux requires entering copy mode (Ctrl+b [). Without this, scrolling affects the outer terminal.
- Nested tmux sessions (tmux inside tmux over SSH) create confusing prefix key conflicts. Use a different prefix for the inner session.
- tmux configuration changes require reloading:
tmux source-file ~/.tmux.confor restarting tmux. - Some terminal emulators have compatibility issues with tmux's terminal capabilities. Use a modern terminal for full feature support.
Frequently Asked Questions
Programs continue running in the background. The tmux server keeps the session alive on the machine. You can reattach later and see output that was generated while you were detached.
tmux is the modern successor to GNU screen. It has a more consistent command interface, better pane management, a scriptable status bar, and active development. Screen still works but tmux is preferred for new setups.
Yes. Add 'set -g mouse on' to your .tmux.conf. This enables mouse-based pane selection, resizing, window switching, and scrolling.
Enter copy mode with Ctrl+b [. Navigate with arrow keys (or vi keys if configured). Press Space to start selection, then Enter to copy. Paste with Ctrl+b ]. Some users configure tmux to sync with the system clipboard.
No. Standard tmux sessions are lost on reboot. Plugins like tmux-resurrect and tmux-continuum can save and restore session layouts, but running processes are still terminated.
Citations (3)
- tmux GitHub— tmux is a terminal multiplexer
- tmux Wiki— tmux manual and configuration
- tmux Man Page— Terminal multiplexer concepts
Related on TokRepo
Discussion
Related Assets
Conda — Cross-Platform Package and Environment Manager
Install, update, and manage packages and isolated environments for Python, R, C/C++, and hundreds of other languages from a single tool.
Sphinx — Python Documentation Generator
Generate professional documentation from reStructuredText and Markdown with cross-references, API autodoc, and multiple output formats.
Neutralinojs — Lightweight Cross-Platform Desktop Apps
Build desktop applications with HTML, CSS, and JavaScript using a tiny native runtime instead of bundling Chromium.