Compare commits

...

3 Commits

Author SHA1 Message Date
Izzy Gomez 23499ea8c5
Merge cbc6f8d909 into cff343cf9e 2024-03-14 15:06:44 -04:00
Izzy Gomez cbc6f8d909
Fix whitespace issue when running `tmux bind-key`.
The previous line `tmux bind-key "$key" $command` would experience issues if there was whitespace in `$command`. This fixes this. Also does small refactor to save `run-shell` commands into `run_{save,restore}_script` vars. Also makes sure keys are unbounded (run `unbind`) before binding (`bind-key`).
2024-03-14 15:02:12 -04:00
Izzy Gomez 23045b74df
confirm actions doc update 2024-03-14 14:00:25 -04:00
2 changed files with 11 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# Confirm save & restore actions
By default save & restore will have no confirmation when the key bindings are pressed. To change this, add to `.tmux.conf`:
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

@ -7,33 +7,37 @@ 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-shell \\\"$CURRENT_DIR/scripts/save.sh\\\"\""
command="confirm-before -y -p \"$confirm_save_prompt\" \"$run_save_script\""
else
command="run-shell \"$CURRENT_DIR/scripts/save.sh\""
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" $command
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-shell \\\"$CURRENT_DIR/scripts/restore.sh\\\"\""
command="confirm-before -y -p \"$confirm_restore_prompt\" \"$run_restore_script\""
else
command="run-shell \"$CURRENT_DIR/scripts/restore.sh\""
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" $command
tmux unbind "$key"
tmux bind-key "$key" "$command"
done
}