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

Allow to forward --bind options to fzf #913

Open
kit494way opened this issue Sep 14, 2024 · 1 comment
Open

Allow to forward --bind options to fzf #913

kit494way opened this issue Sep 14, 2024 · 1 comment
Labels
new feature New feature or request

Comments

@kit494way
Copy link
Contributor

kit494way commented Sep 14, 2024

Is your feature request related to a problem? Please describe.
I'd like to select a query, whether single or multiple selections.

Currently, for single selection, the <tab> key is bound to select a query, and this key binding is hard coded.
For multiple selection, there are no key bindings to select a query, and <tab> is used to toggle selection.
I'd like to use same key (e.g. ctrl-y) to select a query for both single and multiple selections.

Describe the solution you'd like
Remove SuggestionType::SingleRecommendation and make SuggestionType::SingleSelection (--prevent-extra option) as default.
Allow to forward --bind options to fzf.
User can select a query by binding print-query action to arbitrary keys.

Example:

config.yaml

finder:
  overrides_var: --reverse --height 16 --cycle --bind 'ctry-y:print-query'

cheatseet

% sample
# sample
echo <word>
$ word: echo -e 'one\ntwo\nthree'

# multiple
echo <words>
$ words: echo -e 'one\ntwo\nthree' --- --multi --map "tr '\n' ' '"

# prevent extra
echo <exact_word>
$ exact_word: echo -e 'one\ntwo\nthree' --- --bind 'ctrl-y:ignore'

Example of print-query actions in fzf are following.

echo -e 'one\ntwo\nthree' | fzf --bind 'ctrl-y:print-query'
echo -e 'one\ntwo\nthree' | fzf --multi --bind 'ctrl-y:print-query'
echo -e 'one\ntwo\nthree' | fzf --bind 'ctrl-y:print-query' --bind 'ctrl-y:ignore' # second binding invalidates first binding

I confirmed with fzf version 0.55.0.

Describe alternatives you've considered
In fact, selecting query can be achieved in the current implementation by setting the following

config.yaml

finder:
  overrides_var: --reverse --height 16 --cycle

cheatseet

% sample
# sample
echo <word>
$ word: echo -e 'one\ntwo\nthree' --- --prevent-extra --fzf-overrides '--reverse --height 16 --cycle --bind "ctrl-y:print-query"'

# multiple
echo <words>
$ words: echo -e 'one\ntwo\nthree' --- --multi --map "tr '\n' ' '" --fzf-overrides '--reverse --height 16 --cycle --bind "ctrl-y:print-query"'

# prevent extra
echo <exact_word>
$ exact_word: echo -e 'one\ntwo\nthree' --- --prevent-extra

This approach is annoying because it requires the --prevent-extra and --fzf-overrides options.

Additional context

@kit494way kit494way added the new feature New feature or request label Sep 14, 2024
Copy link

welcome bot commented Sep 14, 2024

Thanks for opening your first issue here! In case you're facing a bug, please update navi to the latest version first. Maybe the bug is already solved! :)

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

No branches or pull requests

1 participant