|
@@ -0,0 +1,117 @@
|
|
|
+>[TOC]
|
|
|
+
|
|
|
+
|
|
|
+# 1、tmux简介
|
|
|
+
|
|
|
+tmux (opens new window)是linux中一种管理窗口的程序,它提供了一个Session随时存储和恢复的功能。
|
|
|
+
|
|
|
+# 2、软件安装
|
|
|
+
|
|
|
+```shell
|
|
|
+# Mac
|
|
|
+$ brew install tmux
|
|
|
+
|
|
|
+# Ubuntu 或 Debian
|
|
|
+$ sudo apt-get install tmux
|
|
|
+
|
|
|
+# CentOS 或 Fedor可以使用yum/dnf/brew等方式安装,brew版本更高些
|
|
|
+$ yum install tmux
|
|
|
+```
|
|
|
+
|
|
|
+# 3、软件的使用
|
|
|
+
|
|
|
+```shell
|
|
|
+# 加载配置文件
|
|
|
+tmux source-file ~/.tmux.conf
|
|
|
+
|
|
|
+# 新建会话
|
|
|
+tmux new -s hdcms
|
|
|
+# 查看会话
|
|
|
+ctrl+b s
|
|
|
+# 重命名会话
|
|
|
+Ctrl+b $
|
|
|
+
|
|
|
+# 创建窗口
|
|
|
+ctrl+b c
|
|
|
+# 切换到2号窗口
|
|
|
+ctrl+b 2
|
|
|
+# 重命名窗口
|
|
|
+ctrl+b ,
|
|
|
+# 关闭窗口
|
|
|
+ctrl+b &
|
|
|
+
|
|
|
+# 水平拆分出一个新窗格
|
|
|
+ctrl+b %
|
|
|
+# 垂直拆分窗格
|
|
|
+ctrl+b "
|
|
|
+# 切换到下一个窗格
|
|
|
+ctrl+b o
|
|
|
+# 关闭窗格
|
|
|
+ctrl+b x
|
|
|
+```
|
|
|
+
|
|
|
+# 4、保存回话
|
|
|
+
|
|
|
+```shell
|
|
|
+# 安装插件
|
|
|
+git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
|
|
|
+git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/resurrect
|
|
|
+
|
|
|
+# 修改配置文件 ~/.tmux.conf添加以下内容
|
|
|
+# 自动保存会话
|
|
|
+set -g @plugin 'tmux-plugins/tpm'
|
|
|
+set -g @plugin 'tmux-plugins/tmux-sensible'
|
|
|
+set -g @plugin 'tmux-plugins/tmux-resurrect'
|
|
|
+set -g @plugin 'tmux-plugins/tmux-continuum'
|
|
|
+set -g @continuum-save-interval '15'
|
|
|
+set -g @continuum-restore 'on'
|
|
|
+set -g @resurrect-capture-pane-contents 'on'
|
|
|
+run '~/.tmux/plugins/tpm/tpm'
|
|
|
+
|
|
|
+run-shell ~/.tmux/plugins/resurrect/resurrect.tmux
|
|
|
+
|
|
|
+# 返回终端重新加载配置项
|
|
|
+tmux source ~/.tmux.conf
|
|
|
+
|
|
|
+# 然后执行命令安装插件,默认的prefix是crl+b
|
|
|
+prefix + I
|
|
|
+
|
|
|
+# 保存会话
|
|
|
+prefix + Ctrl-s
|
|
|
+
|
|
|
+# 恢复会话
|
|
|
+prefix + Ctrl-r
|
|
|
+
|
|
|
+```
|
|
|
+
|
|
|
+# 5、常用快捷键
|
|
|
+
|
|
|
+## 5.1、窗格快捷键
|
|
|
+
|
|
|
+| **快捷键** | **说明** |
|
|
|
+| ----------------- | ------------------------------------------ |
|
|
|
+| Ctrl+b % | 划分左右两个窗格 |
|
|
|
+| Ctrl+b " | 划分上下两个窗格 |
|
|
|
+| Ctrl+b ; | 切换到上一个窗格 |
|
|
|
+| Ctrl+b o | 光标切换到下一个窗格 |
|
|
|
+| Ctrl+b { | 当前窗格左移 |
|
|
|
+| Ctrl+b } | 当前窗格右移 |
|
|
|
+| Ctrl+b Ctrl+o | 当前窗格上移 |
|
|
|
+| Ctrl+b Alt+o | 当前窗格下移 |
|
|
|
+| Ctrl+b x | 关闭当前窗格 |
|
|
|
+| Ctrl+b ! | 将当前窗格拆分为一个独立窗口 |
|
|
|
+| Ctrl+b z | 当前窗格全屏显示,再使用一次会变回原来大小 |
|
|
|
+| Ctrl+b q | 显示窗格编号 |
|
|
|
+| Ctrl+b Alt+方向键 | 调整窗格大小 |
|
|
|
+
|
|
|
+## 5.2、窗口管理
|
|
|
+
|
|
|
+| 快捷键 | 说明 |
|
|
|
+| -------- | ------------------------------------------------- |
|
|
|
+| Ctrl+b p | 切换到上一个窗口(按照状态栏上的顺序) |
|
|
|
+| Ctrl+b n | 切换到下一个窗口 |
|
|
|
+| Ctrl+b | 切换到指定编号的窗口,number 是状态栏上的窗口编号 |
|
|
|
+| Ctrl+b w | 从列表中选择窗口 |
|
|
|
+| ctrl+b & | 关闭当前窗口 |
|
|
|
+| ctrl+b x | 删除窗口 |
|
|
|
+
|