恢复窗口配置:
首先查看
tmux
版本:
resurrect插件需要
tmux
1.9以上的版本。如果你的版本低于1.9,那么升级是必须的,其实把
tmux
升级到1.9以上还是蛮推荐的。
这里推荐安装tpm (Tmux Plugin Manager)做
tmux
插件管理,再通过
tpm
安装continuum等插件:
编辑
~/.tmux.conf
,在文件末尾加入以下几行:
# Set default shell to zsh
# set-option -g default-shell /bin/zsh
# Use the following line to fix OS X tmux problems
# set-option -g default-command "reattach-to-user-namespace -l zsh"
# List of plugins
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'
# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin '[email protected]/user/plugin'
# set -g @plugin '[email protected]/user/plugin'
# Enable automatic restore
set -g @continuum-restore 'on'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
如果你的默认shell是
zsh
,请把这句的注释去掉:
如果你用的是Mac OSX,把这句的注释也去掉:
这主要是
tmux
在OSX下水土不服(更详细的问题描述可以看这篇文章:Reattach-to-user-namespace: The Fix for Your Tmux in OS X Woes),需要用reattach-to-user-namespace黑科技,所以你最好也用MacPorts或者Homebrew装下这个工具:
在终端下执行以下命令更新
tmux
配置,运行
tpm
:
最后在
tmux
下运行
prefix + I
(如果你没改键绑定的话就是
<Ctrl>-b + <Shift>-i
)安装插件。你还可以通过
prefix + U
(
<Ctrl>-b + <Shift>-u
)更新插件,用
prefix + <Alt> + u
删除插件。
安装完成之后,你可以在
~/.tmux/plugins/
里找到每个插件的代码目录。resurrect插件还有一个
run_tests
脚本用于检查是否安装正确,不过要运行这个脚本需要装上虚拟化神器vagrant。
如果安装正确,continuum插件会每隔15分钟产生一份备胎,我们也可以用
prefix + <Ctrl>-s
手动备份,用
prefix + <Ctrl>-r
手动恢复.
参考链接:
http://blog.csdn.net/robertbaker/article/details/42172203
https://segmentfault.com/a/1190000006232298
<code><span class="pln"><span style="font-size: 14px;">
</span></span></code>