junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
64.33k stars 2.38k forks source link

Unknown command fzf_key_bindings error when invoking read in a Fish shell script #3786

Closed chrycheng closed 4 months ago

chrycheng commented 4 months ago

Checklist

Output of fzf --version

0.51.0 (brew)

OS

Shell

Problem / Steps to reproduce

❯ cat fzf_read_issue.fish
#!/usr/bin/env fish

read
❯ read
read>
❯ ./fzf_read_issue.fish
fish: Unknown command: fzf_key_bindings
~/.config/fish/functions/fish_user_key_bindings.fish (line 2):
  fzf_key_bindings
  ^~~~~~~~~~~~~~~^
in function 'fish_user_key_bindings'
        called on line 187 of file ./fzf_read_issue.fish
in function '__fish_reload_key_bindings'
        called on line 192 of file /home/linuxbrew/.linuxbrew/Cellar/fish/3.7.1/share/fish/functions/__fish_config_interactive.fish
in function '__fish_config_interactive'
in function '__fish_on_interactive'
        called on line 1 of file ./fzf_read_issue.fish
in event handler: handler for generic event 'fish_read'
        called on line 3 of file ./fzf_read_issue.fish
read>
❯
junegunn commented 4 months ago

We're recommending a new way to set up shell integration.

https://github.com/junegunn/fzf?tab=readme-ov-file#setting-up-shell-integration

Try following the new instructions and removing the fzf_key_bindings line from ~/.config/fish/functions/fish_user_key_bindings.

chrycheng commented 4 months ago

That did the trick. So, did I just miss an upgrade step instruction somewhere? Or is this a gap in the documentation?

junegunn commented 4 months ago

I'm not sure.

Though we recommend the new way, the old configuration should still work because key-bindings.fish file is still in the Homebrew package.

https://github.com/Homebrew/homebrew-core/blob/4da46e295cc5fc312766b9d1b7cce329c7025a8f/Formula/f/fzf.rb#L33

The old install script would

  1. Symlink the file to ${fish_dir}/functions/fzf_key_bindings.fish
  2. And add fzf_key_bindings to ${fish_dir}/functions/fish_user_key_bindings.fish

So unless you removed the symlink, it should still work.

https://github.com/junegunn/fzf/commit/e74b1251c0f579335e03b3e7182cd7a9f88dbe37#diff-1e142e6277b12b7e1110478a24caee8f006a9349e86970c890203d6266209463L285-L295

Maybe you removed the symlink and only kept fzf_key_bindings line?