Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add confirm option for save and restore. #502

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

izzygomez
Copy link

Overview of PR

  • Implemented support for optional @resurrect-confirm-save & @resurrect-confirm-restore options. These new options make use of tmux's confirm-before command (see man tmux) to ask for confirmation before saving or restoring the tmux environment.
  • Updated docs to explain usage.
  • Set default values to off so that current out-of-the-box plugin experience is not changed.

Motivation

I found myself accidentally saving & restoring my tmux environment because of their key binding similarity to other common actions I do (e.g. <Prefix>+s to list tmux sessions, <Prefix>+r to reload .tmux.conf), so I wanted to add a confirmation step to save & restore actions when using the tmux-resurrect plugin.

Screenshots

Example .tmux.conf changes to use these new options
image

Confirmation message for save action
image

Confirmation message for restore action
image

izzygomez added a commit to izzygomez/dotfiles that referenced this pull request Mar 14, 2024
*this depends on support for upstream changes that I'm making to plugin here: tmux-plugins/tmux-resurrect#502
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`).
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'
Copy link

@shabaev shabaev Mar 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a typo - ressurect-confirm-...

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\""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jfyi - tmux 3.2a-4ubuntu0.2 - -y is unknown option

@leokang94
Copy link

Hello! any updates?

@izzygomez
Copy link
Author

Hello! any updates?

Hey, I wrote the original PR here & might eventually get around to implementing fixes requested, but this project seems somewhat dead as they haven't accepted any PRs in over a year, so there's no real incentive.

@Fatjon-Gash1
Copy link

This PR should be accepted. An optional confirmation part is suitable for users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants