# 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. ## Install Save in your project root: ## Quick Use ```bash # Install brew install tmux # macOS sudo apt install tmux # Debian/Ubuntu ``` Basic workflow (default prefix `Ctrl+b`): ```bash tmux new -s work # Create session named work tmux ls # List sessions tmux attach -t work # Reattach tmux kill-session -t work # Kill session ``` Inside tmux (after `Ctrl+b`): - `c` — new window - `n` / `p` — next / prev window - `%` — split vertical - `"` — split horizontal - `arrows` — move between panes - `d` — detach session - `z` — zoom current pane - `[` — copy mode (scroll with arrows) ## Intro tmux (terminal multiplexer) lets you run multiple terminal sessions inside a single window. Create windows and panes, detach them (sessions keep running), and reattach later from any terminal — even after SSH disconnects. Essential tool for servers, long-running scripts, and pair programming. - **Repo**: https://github.com/tmux/tmux - **Stars**: 44K+ - **Language**: C - **License**: ISC ## What tmux Does - **Sessions** — top-level containers with multiple windows - **Windows** — full-screen tabs inside a session - **Panes** — splits inside a window - **Detach/attach** — keep sessions running in background - **Scripting** — `tmux send-keys` to drive panes - **Copy mode** — navigate scrollback, select, copy - **Customization** — `.tmux.conf` for prefix, status bar, colors - **Plugins** — via TPM (tmux plugin manager) ## Architecture tmux runs a server process that owns sessions. Clients (terminals) attach to the server. Multiple clients can attach to the same session for mirror/pair sessions. State persists across client disconnects. ## Self-Hosting CLI tool. ## Key Features - Sessions survive logout/SSH disconnect - Multiple windows + panes - Copy mode with vi or emacs keybinds - Scriptable via CLI - Customizable status bar - Plugin ecosystem (TPM) - Works over ssh and mosh - Synchronized panes for running same cmd in multiple ## Comparison | Tool | Type | Config | Sessions | |---|---|---|---| | tmux | TUI | .tmux.conf | Yes | | screen | TUI | .screenrc | Yes | | Zellij | TUI (Rust) | YAML/KDL | Yes | | Byobu | tmux/screen wrapper | Simplified | Yes | | iTerm2 | GUI | GUI prefs | Yes (in-app) | ## 常见问题 FAQ **Q: 学习曲线?** A: 记住 prefix(默认 Ctrl+b)+ 10 个快捷键就能基本用。高级功能(resize、copy mode、macros)按需学。 **Q: 和 Zellij 比?** A: Zellij 更现代(Rust、开箱即用 UI、图层预设),但 tmux 生态更成熟、服务器更稳定。 **Q: SSH 断开怎么办?** A: 这正是 tmux 的价值。`tmux new -s main` 后运行任务,断开后 `ssh` 回来 `tmux attach -t main` 一切如初。 ## 来源与致谢 Sources - GitHub: https://github.com/tmux/tmux - License: ISC --- Source: https://tokrepo.com/en/workflows/6ed07802-35cb-11f1-9bc6-00163e2b0d79 Author: AI Open Source