Tmux 是終端多工器,提供會話持久化、窗口分割、面板管理、跨 SSH 會話恢復等能力,是遠端開發、長時間任務運行的必備神器。本文涵蓋安裝、三大核心概念、全快捷鍵表、進階美化配置。
# macOS (Homebrew) brew install tmux # Ubuntu/Debian sudo apt install tmux # CentOS/RHEL sudo yum install tmux
關係:Session ⊃ Window(s) ⊃ Pane(s)
Ctrl+b 開頭(按下後釋放,再按功能鍵)| 操作 | 快捷鍵/命令 |
|---|---|
| 新建會話 | tmux new -s name |
| 列出會話 | tmux ls 或 Ctrl+b s |
| 附著會話 | tmux attach -t name |
| 分離會話 | Ctrl+b d |
| 在會話中建新會話 | Ctrl+b : new -s newname |
| 操作 | 快捷鍵 |
|---|---|
| 新建窗口 | Ctrl+b c |
| 關閉窗口 | Ctrl+b & |
| 列出窗口 | Ctrl+b w |
| 上/下一窗口 | Ctrl+b p / n |
| 跳轉指定窗口 | Ctrl+b 0-9 |
| 重命名窗口 | Ctrl+b , |
| 操作 | 快捷鍵 |
|---|---|
| 橫向分割(上下) | Ctrl+b " |
| 縱向分割(左右) | Ctrl+b % |
| 切換面板 | Ctrl+b 方向鍵 |
| 關閉面板 | Ctrl+b x |
| 顯示面板編號 | Ctrl+b q |
cd ~ rm -rf .tmux git clone https://github.com/gpakosz/.tmux.git ln -s .tmux/.tmux.conf cp .tmux/.tmux.conf.local .
Ctrl+a(更順手)兼容 Ctrl+b。掌握 Tmux,讓終端工作流具備「存檔、載入、分屏、遠程無縫銜接」的超能力。