junegunn / junegunn/fzf

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

Open
#4,576 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
83k
Forks
2.9k
Avg merge
17h 8m
Merged PRs (30d)
10

Description

### 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:
```bash
# `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 ={})
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with fzf's --bind event handling and the become(...) action, using the existing jump, jump-cancel, and reload events as references. Determine how an accept-related event should interact with user-defined accept bindings and verify the example bash script works without hard-coded keys. Done means the selected item triggers become through the new event while existing bindings remain compatible.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.