tmux 终端复用器:单窗口多会话,断开后保持运行,支持窗口/窗格分割。
安装与启动
1
2
3
4
5
6
7
| # 安装
sudo apt install tmux # Debian/Ubuntu
sudo dnf install tmux # RHEL/Fedora
# 启动
tmux # 新会话
tmux new -s my_session # 命名会话
|
会话管理
| 操作 | 命令 |
|---|
| 分离 | Ctrl-b d |
| 列出 | tmux ls |
| 重连 | tmux attach -t 名称 |
| 删除 | tmux kill-session -t 名称 |
| 全部删除 | tmux kill-server |
窗口操作
| 操作 | 快捷键 |
|---|
| 新建 | Ctrl-b c |
| 下/上窗口 | Ctrl-b n / p |
| 列表 | Ctrl-b w |
| 重命名 | Ctrl-b , |
窗格操作
| 操作 | 快捷键 |
|---|
| 垂直分割 | Ctrl-b % |
| 水平分割 | Ctrl-b " |
| 切换 | Ctrl-b 方向键 |
| 关闭 | exit 或 Ctrl-d |
配置
1
2
3
4
| # ~/.tmux.conf
set -g prefix C-a # 前缀改为 Ctrl-a
set -g mouse on # 启用鼠标
bind r source-file ~/.tmux.conf \; display "Reloaded!"
|
会话持久化
1
2
3
4
5
6
7
8
| # 安装 TPM
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# ~/.tmux.conf
set -g @plugin 'tmux-plugins/tmux-resurrect'
run '~/.tmux/plugins/tpm/tpm'
# prefix + I 安装,prefix + Ctrl-s 保存,prefix + Ctrl-r 恢复
|
Comments