Save and restore hooks

This commit is contained in:
Sergey Vlasov
2018-01-19 18:36:13 +02:00
committed by Ash Berlin-Taylor
parent 42f77b303c
commit 0133c7a96a
6 changed files with 38 additions and 0 deletions

View File

@ -148,3 +148,14 @@ resurrect_history_file() {
local shell_name="$2"
echo "$(resurrect_dir)/${shell_name}_history-${pane_id}"
}
# hook helpers
save_hook() {
get_tmux_option "$save_hook_option" "$save_hook_default"
}
restore_hook() {
get_tmux_option "$restore_hook_option" "$restore_hook_default"
}

View File

@ -344,6 +344,9 @@ restore_active_and_alternate_sessions() {
main() {
if supported_tmux_version_ok && check_saved_session_exists; then
start_spinner "Restoring..." "Tmux restore complete!"
if [ -n "$(restore_hook)" ]; then
eval "$(restore_hook)"
fi
restore_all_panes
restore_pane_layout_for_each_window >/dev/null 2>&1
if save_shell_history_option_on; then

View File

@ -314,6 +314,9 @@ main() {
stop_spinner
display_message "Tmux environment saved!"
fi
if [ -n "$(save_hook)" ]; then
eval "$(save_hook)"
fi
fi
}
main

View File

@ -42,3 +42,9 @@ shell_history_option="@resurrect-save-shell-history"
# set to 'on' to ensure panes are never ever overwritten
overwrite_option="@resurrect-never-overwrite"
# Hooks
restore_hook_default=""
restore_hook_option="@resurrect-restore-hook"
save_hook_default=""
save_hook_option="@resurrect-save-hook"