恢復窗口配置:
首先查看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 '[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
,請把這句的註釋去掉:
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
<code><span class="pln"><span style="font-size: 14px;"> </span></span></code>