1. 詳細(xì)步驟
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 內(nèi)使用
1.3.1 當(dāng)前窗口下再開一個終端
ctrl + b + c
1.3.2 切換終端窗口
ctrl + b + w,上下移動+回車來選擇某個終端窗口,或者輸入終端窗口序號(前面的 1-9 數(shù)字等)
1.3.3 關(guān)閉當(dāng)前終端
exit
注:如果 xxx 下沒有別的終端窗口了,會退出 tmux
1.3.4 退出 tmux(掛起所有 tmux 終端)
ctrl + b + d
1.4 安裝 Tmux Resurrect 插件(支持 Tmux 終端備份)
只會恢復(fù)終端窗口,服務(wù)還是要自己啟動
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
注:確保網(wǎng)絡(luò)通暢
1.4.1.3 vim ~/.tmux.conf
run-shell "~/.tmux/plugins/tmux-resurrect/resurrect.tmux"
注:添加以上內(nèi)容到 ~/.tmux.conf
1.4.1.4 source file
tmux source-file ~/.tmux.conf
1.4.2 使用
進(jìn)入 tmux 開啟的終端窗口,ctrl + b + ctrl + s,看到 Tmux environment saved! 就說明保存成功了
1.4.3 驗(yàn)證
重啟系統(tǒng),新建一個 tmux 窗口,輸入 ctrl + b + ctrl + r,看到 Tmux restore complete! 就說明恢復(fù)成功了
注:不重啟系統(tǒng),直接恢復(fù)也可以
2. 資源
2.1 Tmux
GitHub
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