tmux恢復窗口配置

恢復窗口配置:

首先查看tmux版本:

tmux -V

resurrect插件需要tmux1.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>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章