Tmux简明教程
参考资料:可能是东半球最全面易懂的 Tmux 使用教程!( 强烈建议收藏 )
Tmux简介
- 会话:用户在终端窗口(进程)中输入命令进行交互,称为一次会话;
- Tmux就是会话与窗口的解绑工具。
基本操作
1. 前缀键:ctrl+b
+ 方向键
:切换窗格
+ alt 方向键
:调整窗格大小
+ n
:切换窗口
+ s (+ 方向键)
:列出所有会话(显示分支结构)
+ x
:关闭当前窗格
+ z
:全屏当前窗格
+ d
:分离当前会话
+ q
:显示窗格编号tmux
2. 会话操作
启动,退出,创建,接入,分离,查看,杀死,重命名,切换0
1 2 3 4 5 6 7 8 9
| tmux # 启动 exit # 退出 tmux new -s <session-name> tmux attach -t <session-name> tmux detach tmux ls tmux kill-session -t <session-name> tmux rename-session -t <target-name> <new-name> tmux switch-session -t <session-name>
|
3. 窗格操作
新建,切换,划分,移动,交换
1 2 3 4 5 6 7 8 9 10 11 12 13
| tmux new-window -n <window-name> tmux select-window -t <window-name> tmux rename-window <new-name>
tmux split-window # up-down tmux split-window -h # left-right
tmux select-pane -U # up tmux select-pane -D # down tmux select-pane -L # left tmux select-pane -R # right
tmux swap-pane -U # -D -L -R
|
4. 我的配置.tmux.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| set -g mouse on # 鼠标滚动支持 set -g default-terminal "screen-256color" set-option -ga terminal-overrides ",*256col*:Tc" set -g status-right '%H:%M:%S %b-%d %A' set -g status-interval 1 # 状态栏刷新时间 set -g status-style bg='#000000',fg=white # 底部命令或者状态栏的颜色 set -g pane-active-border-style fg=red,bg=black # 设置正在使用的窗口的边界颜色,在不同窗口切换时边界颜色会变化 set -sg escape-time 1 set -g status-position bottom bind | split-window -h -c '#{pane_current_path}' bind - split-window -v -c '#{pane_current_path}' bind-key N run "tmux new-window -c '#{pane_current_path}' -t $(($(tmux display-message -p '#I') + 1))" bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R
|