ConfigsApr 11, 2026·3 min read

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.

TL;DR
tmux lets you manage terminal sessions with detach, reattach, windows, and split panes.
§01

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.

§02

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.

§03

How to use

  1. Install tmux.
  2. Start a new session.
  3. Use key bindings to manage panes and windows.
  4. 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
§04

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
§05

Related on TokRepo

§06

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.conf or restarting tmux.
  • Some terminal emulators have compatibility issues with tmux's terminal capabilities. Use a modern terminal for full feature support.

Frequently Asked Questions

What happens to my programs when I detach from tmux?+

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.

How is tmux different from screen?+

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.

Can I use the mouse in tmux?+

Yes. Add 'set -g mouse on' to your .tmux.conf. This enables mouse-based pane selection, resizing, window switching, and scrolling.

How do I copy text in tmux?+

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.

Can tmux sessions survive a server reboot?+

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)

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets