fzf icon indicating copy to clipboard operation
fzf copied to clipboard

How to selectively disable Ctrl+R shell keybinding (while NOT disabling Alt+C & others), e.g. for fish 3.6.0

Open ronjouch opened this issue 2 years ago • 3 comments

  • [x] I have read through the manual page (man fzf)
  • [x] I have the latest version of fzf (0.35.1 a38b63b)
  • [x] I have searched through the existing issues

Info

  • OS: Linux
  • Shell: fish 3.6.0

Problem / Steps to reproduce

Version 3.6.0 of the Fish shell, released today, ships a default searchable interactive history bound to the typical Ctrl+R shell key binding: https://github.com/fish-shell/fish-shell/issues/602 . It does a great job, and because it's specialized to fish, it does a few nice things fzf doesn't, like syntax highlighting.

So, I'd like to migrate from fzf Ctrl+R shell keybinding to it...

... but I also want to keep being able to use fzf's Alt+C ! I want to only disable fzf's Ctrl+R shell keybinding but I do not want to disable fzf's Alt+C.

→ How can I selectively disable fzf's Ctrl+R shell keybinding while keeping fzf's Alt+C keybinding working? So far my attempt was to no longer call fzf_key_bindings in my fish config, but of couse it disables all keybindings 😕. Is there more granular configuration?

Thanks for the help and thanks for fzf!

Alternative

Alternatively, maybe fzf should detect it's running in fish ≥ 3.6.0, and not register the Ctrl+R shell keybinding?

ronjouch avatar Jan 07 '23 15:01 ronjouch

Speaking with my fish dev hat on: There's no need for fzf to do anything, you can just erase its ctrl-r binding right after fzf bound it:

fzf_key_bindings
bind --erase \cr

This will restore the preset binding, which is fish's "history-pager".

faho avatar Jan 08 '23 18:01 faho

Speaking with my fish dev hat on: There's no need for fzf to do anything, you can just erase its ctrl-r binding right after fzf bound it:

@faho thaaaaaaaaaank youuuuuuuuuuuuuuuuuu! Confirmed working!

@ fzf triagers/maintainers: leaving this issue open, as:

  1. Maybe fzf could do something else (see "Alternative" paragraph of this issue)
  2. Maybe you want an option anyway
  3. Minimally, fzf may want to mention/document this

ronjouch avatar Jan 08 '23 18:01 ronjouch

@faho now that I think of it, in addition to fzf needing to document it, since fzf is popular and its default Ctrl+R will override / "hide" the new fish Ctrl+R, maybe it'd be worthwhile to mention this in fish's changelog? What about something like this added to fish's CHANGELOG.rst? (And maybe even to the full keybindings docs?)

  • fzf users: fzf_key_bindings will override fish's new Ctrl+R. In order to both load fzf for other features, AND have the new fish Ctrl+R history, call bind --erase \cr after fzf_key_bindings .

It may help limit cases of "New fish Ctrl+R doesn't work for me" issues.

ronjouch avatar Jan 08 '23 19:01 ronjouch