恢複視窗配置:
首先檢視
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>