[question] Action to toggle multi selection
DanSM-5 opened this issue · comments
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.0 (0.50.0)
OS
- Linux
- macOS
- Windows
- Etc.
Shell
- bash
- zsh
- fish
Problem / Steps to reproduce
Is there an action that toggles multi
to allow you to select multiple options or restrict to a single option through a binding?
I couldn't find any toggle-multi
action or a select/deselect action that would do something similar.
No. Do you have a use case?
Yes. I have some scripts that do a multi purpose selection but some make sense to restrict the selection to a single item.
A simple example from one of my scripts
getsources |
fzf --multi \
--prompt 'Projects> ' \
--multi \
--bind 'ctrl-f:change-prompt(Files> )+reload(fd --type file . {})+unbind(ctrl-f)' \
--bind 'ctrl-p:change-prompt(Projects> )+reload(getsources)+rebind(ctrl-f)'
I'm expecting either multiple files or a single directory. At the moment I added a check for the first item so if I accidentally select multiple directories, it just picks the first one and ignores the rest to prevent errors. It would be nice though if I could change the multi
state as an action when picking directories so I can avoid validation logic. I imagine this can be useful for other multi purpose selection.
Yeah, in that case, change-multi(LIMIT)
would make sense.
change-multi
:--multi
(unlimited)change-multi(0)
:--no-multi
change-multi(N)
:--multi N
(maximum N items)
toggle-multi
will not be very useful.
I agree, if you can set N
number of items, it would be better.
Please note that change-multi
will clear previous selections. I couldn't think of any use case where you would want to keep the previous selections, so I just decided to keep it simple.
I think that works fine. Thanks!