pull/502/merge
Izzy Gomez 2024-03-14 15:06:44 -04:00 committed by GitHub
commit 23499ea8c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 35 additions and 2 deletions

View File

@ -90,6 +90,7 @@ You should now be able to use the plugin.
**Configuration**
- [Changing the default key bindings](docs/custom_key_bindings.md).
- [Adding a confirmation step on save & restore](docs/confirm_actions.md).
- [Setting up hooks on save & restore](docs/hooks.md).
- Only a conservative list of programs is restored by default:<br/>
`vi vim nvim emacs man less more tail top htop irssi weechat mutt`.<br/>

6
docs/confirm_actions.md Normal file
View File

@ -0,0 +1,6 @@
# Confirm save & restore actions
By default save & restore will have no confirmation step when the key bindings are pressed. To change this, add to `.tmux.conf`:
set -g @resurrect-save-confirm 'on'
set -g @resurrect-restore-confirm 'on'

View File

@ -6,18 +6,38 @@ source "$CURRENT_DIR/scripts/variables.sh"
source "$CURRENT_DIR/scripts/helpers.sh"
set_save_bindings() {
local should_confirm_save=$(get_tmux_option "$confirm_save_option" "$default_confirm_save")
local run_save_script="run-shell \"$CURRENT_DIR/scripts/save.sh\""
local command
if [ "$should_confirm_save" == "on" ]; then
command="confirm-before -y -p \"$confirm_save_prompt\" \"$run_save_script\""
else
command="$run_save_script"
fi
local key_bindings=$(get_tmux_option "$save_option" "$default_save_key")
local key
for key in $key_bindings; do
tmux bind-key "$key" run-shell "$CURRENT_DIR/scripts/save.sh"
tmux unbind "$key"
tmux bind-key "$key" "$command"
done
}
set_restore_bindings() {
local should_confirm_restore=$(get_tmux_option "$confirm_restore_option" "$default_confirm_restore")
local run_restore_script="run-shell \"$CURRENT_DIR/scripts/restore.sh\""
local command
if [ "$should_confirm_restore" == "on" ]; then
command="confirm-before -y -p \"$confirm_restore_prompt\" \"$run_restore_script\""
else
command="$run_restore_script"
fi
local key_bindings=$(get_tmux_option "$restore_option" "$default_restore_key")
local key
for key in $key_bindings; do
tmux bind-key "$key" run-shell "$CURRENT_DIR/scripts/restore.sh"
tmux unbind "$key"
tmux bind-key "$key" "$command"
done
}

View File

@ -2,10 +2,16 @@
default_save_key="C-s"
save_option="@resurrect-save"
save_path_option="@resurrect-save-script-path"
default_confirm_save="off"
confirm_save_option="@resurrect-confirm-save"
confirm_save_prompt="Save tmux environment? (Y/n)"
default_restore_key="C-r"
restore_option="@resurrect-restore"
restore_path_option="@resurrect-restore-script-path"
default_confirm_restore="off"
confirm_restore_option="@resurrect-confirm-restore"
confirm_restore_prompt="Restore tmux environment? (Y/n)"
# default processes that are restored
default_proc_list_option="@resurrect-default-processes"