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

Action to clear selections if there are any else exit fzf. (Feature request) #3805

Open
4 of 10 tasks
smashgen opened this issue May 18, 2024 · 1 comment
Open
4 of 10 tasks

Comments

@smashgen
Copy link

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.50 (devel)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

I checked the man page and I don't think there is an action that already does this. I think it would be useful to have an action that clears selections if there are any else exit fzf, similar to the cancel action.

@LangLangBart
Copy link
Contributor

LangLangBart commented May 18, 2024

The transform1 action enables the user to execute an action conditionally.


Example

The fzf tool sets the environment variable FZF_SELECT_COUNT2. If no selections are present, the operation is aborted. Otherwise, it deselects the matches upon pressing ⌃ Control + A.

look foo | fzf --multi \
  --bind 'load:select-all' \
  --bind 'ctrl-a:transform:((FZF_SELECT_COUNT)) &&
    echo "deselect-all" ||
    echo "abort"'

Footnotes

  1. changelog 0.45.0

  2. changelog 0.46.0

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

No branches or pull requests

2 participants