概述
tmux 用了很長時間了, 快捷鍵定制了不少, 唯一的遺憾是沒法保存 session, 每次關機重開之后, 恢復不到之前的 tmux session. 雖然也能忍受, 但是每天都手動打開之前的 session, 總覺得有些麻煩, 直到找到了 tmux-resurrect
tmux-resurrect 可以方便的保存和恢復 tmux session.
安裝
可以直接安裝, 也可以通過 tpm 來安裝, tpm(tmux package management)可以非常方便的安裝和卸載 tmux plugin
tpm 安裝
tpm 路徑: https://github.com/tmux-plugins/tpm
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
復制如下內容到 ~/.tmux.conf
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'
重啟 tmux 之后, 就安裝完成了
tmux-resurrect 安裝
在上面的 #List of plugins 下面添加 tmux-resurrect plugin
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect' # <-- 這個是新添加的
重啟 tmux 之后, 輸入 prefix + I, 就會自動安裝 plugin
使用
tmux-resurrect 的使用非常簡單, 默認的保存和恢復 session 的快捷鍵如下:
- prefix + Ctrl-s Save
- prefix + Ctrl-r Restore