Command | Tmux 安装使用(含终端窗口备份)

1. 详细步骤

1.1 安装 Tmux

apt
sudo apt update && sudo apt install tmux
brew
brew update && brew install tmux

1.2 终端新建/激活 Tmux

1.2.1 新开一个窗口
tmux new -s xxx
1.2.2 激活指定窗口
tmux attach -t xxx

1.3 Tmux 内使用

1.3.1 当前窗口下再开一个终端

ctrl + b + c

1.3.2 切换终端窗口

ctrl + b + w,上下移动+回车来选择某个终端窗口,或者输入终端窗口序号(前面的 1-9 数字等)

1.3.3 关闭当前终端
exit

注:如果 xxx 下没有别的终端窗口了,会退出 tmux

1.3.4 退出 tmux(挂起所有 tmux 终端)

ctrl + b + d

1.4 安装 Tmux Resurrect 插件(支持 Tmux 终端备份)

只会恢复终端窗口,服务还是要自己启动

1.4.1 安装
1.4.1.1 mkdir
mkdir -p ~/.tmux/plugins && cd ~/.tmux/plugins
1.4.1.2 clone repo
git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins

注:确保网络通畅

1.4.1.3 vim ~/.tmux.conf
run-shell "~/.tmux/plugins/tmux-resurrect/resurrect.tmux"

注:添加以上内容到 ~/.tmux.conf

1.4.1.4 source file
tmux source-file ~/.tmux.conf
1.4.2 使用

进入 tmux 开启的终端窗口,ctrl + b + ctrl + s,看到 Tmux environment saved! 就说明保存成功了

1.4.3 验证

重启系统,新建一个 tmux 窗口,输入 ctrl + b + ctrl + r,看到 Tmux restore complete! 就说明恢复成功了

注:不重启系统,直接恢复也可以

2. 资源

2.1 Tmux

GitHub

https://github.com/tmux/tmux

Docs

https://github.com/tmux/tmux/wiki/Getting-Started

2.2 Tmux Plugins

2.2.1 Tmux Resurrect

https://github.com/tmux-plugins/tmux-resurrect

2.2.2 Tmux Continuum

https://github.com/tmux-plugins/tmux-continuum

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值