恢复窗口配置:
首先查看tmux
版本:
tmux -V
resurrect插件需要tmux
1.9以上的版本。如果你的版本低于1.9,那么升级是必须的,其实把tmux
升级到1.9以上还是蛮推荐的。
这里推荐安装tpm (Tmux Plugin Manager)做tmux
插件管理,再通过tpm
安装continuum等插件:
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
编辑~/.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 'git@github.com/user/plugin'
# set -g @plugin 'git@bitbucket.com/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
,请把这句的注释去掉:
set-option -g default-shell /bin/zsh
如果你用的是Mac OSX,把这句的注释也去掉:
set-option -g default-command "reattach-to-user-namespace -l zsh"
这主要是tmux
在OSX下水土不服(更详细的问题描述可以看这篇文章:Reattach-to-user-namespace: The Fix for Your Tmux in OS X Woes),需要用reattach-to-user-namespace黑科技,所以你最好也用MacPorts或者Homebrew装下这个工具:
port install tmux-pasteboard
brew install reattach-to-user-namespace
在终端下执行以下命令更新tmux
配置,运行tpm
:
tmux source ~/.tmux.conf
最后在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