利器之TMUX
用法
- tmux ls : list sessions
- tmux attach -t 0 : -t 代表“target” , 0 是session名
- tmux kill-session -t 0 : 结束会话
- tmux source ~/.tmux.conf : 重新加载配置
- 复制和粘贴: 使用Shift临时禁用tmux,然后Ctrl+Shift+C / Ctrl+Shift+V
常用快捷键
Key | Description |
---|---|
C-b (Ctrl-b) 或者 C-a | Send the prefix key |
m | 鼠标模式 |
M (Alt, meta key) | |
prefix c | new-window |
prefix " | split-window |
prefix % | split-window -h |
prefix z | resize-pane -Z |
prefix $ | Rename the current session |
prefix , | Rename the current window |
prefix M-1 | select-layout even-horizontal |
prefix M-2 | select-layout even-vertical |
prefix M-3 | select-layout main-horizontal |
prefix M-4 | select-layout main-vertical |
prefix M-5 | select-layout tiled |
流行配置
如果懒得折腾,有个流行的通用配置已经够用。见一套常用配置
cd
git clone https://github.com/gpakosz/.tmux.git
ln -s -f .tmux/.tmux.conf
cp .tmux/.tmux.conf.local .
# 编辑~/.tmux.conf.local 以定制自己的新需求
小技巧
技巧1: 总是保留一个会话
终端启动时先运行
tmux attach -t base || tmux new -s base
技巧2: 多面板命令同步
把当前输入发送到当前窗口的所有面板
setw synchronise-panes
技巧3: 缩放
prefix + z放大当前面板, 再次输入恢复。
资源及参考
- Manual
- 10 Killer Tmux Tips
- 其他插件
- Vim Tmux Navigator
- Tmuxinator 也是用于管理会话的