1. 下载插件
打开终端, 执行以下命令:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
git clone https://git::@github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/tmux-resurrect
2. 配置
在 ~/.tmux.conf
中添加以下配置
# 启用插件管理器
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tpm'
bind r source-file ~/.tmux.conf \; display "Reloaded!"
3. 安装插件
打开终端, 执行以下命令:
tmux source-file ~/.tmux.conf
~/.tmux/plugins/tpm/scripts/install_plugins.sh
4. 使用
前缀 Prefix 通常是 ctrl + b
保存回话:
`ctrl-b + ctrl-s`` 保存 tmux session
电脑重启后. 进入 tmux
然后按以下快捷键:
ctrl-b + ctrl-r
恢复 tmux 最后一次保存的 tmux session
其他
如果遇到错误:
unknown variable: TMUX_PLUGIN_MANAGER_PATH
FATAL: Tmux Plugin Manager not configured in tmux.conf
Aborting.
可以在配置文件以面添加 set-environment -g TMUX_PLUGIN_MANAGER_PATH "$HOME/.tmux/plugins/"
再执行第 3 步