fzf icon indicating copy to clipboard operation
fzf copied to clipboard

Feature Request: add `accept` / `accepted` / `on_accept` event

Open andreihh opened this issue 2 months ago • 2 comments

Checklist

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

Output of fzf --version

0.66.1

OS

  • [x] Linux
  • [ ] macOS
  • [ ] Windows
  • [ ] Etc.

Shell

  • [x] bash
  • [ ] zsh
  • [ ] fish

Problem / Steps to reproduce

The become(...) action is extremely useful for writing scripts, but it can be bound via --bind only to explicit key bindings or events.

This means that scripts that execute a command on the selected item must hard-code the accept key bindings, which might not comply with the user's fzfrc or FZF_DEFAULT_OPTS.

Having an accept / accepted / on_accept event, similar to jump / jump-cancel / reload / etc., would allow scripts to execute commands on the selection regardless of the user's key bindings for the accept action.

Example script:

# `enter` and `tab` are bound to `accept`
tmux ls -F "#S" | fzf --tmux \
  --prompt='Session> ' \
  --bind='enter:become(tmux switch -t ={})' \
  --bind='tab:become(tmux switch -t ={})' \
  --bind='jump:become(tmux switch -t ={})'
# This doesn't work:
#   --bind='accept:become(tmux switch -t ={})

andreihh avatar Nov 03 '25 23:11 andreihh

So the default action bound to that event is going to be accept, right? The suggestion has merit, I'll think about it, thanks.

By the way, you can write --bind='enter,tab,jump:become(tmux switch -t ={})' since 0.59.0.

junegunn avatar Nov 04 '25 00:11 junegunn

So the default action bound to that event is going to be accept, right?

Yes, exactly. Thanks for looking into this!

andreihh avatar Nov 04 '25 17:11 andreihh