FZF_CTRL_R_OPTS to support ctrl-o to execute and prepare next commad
- Dominant language
- Go
- Stars
- 83k
- Forks
- 2.9k
- Avg merge
- 17h 8m
- Merged PRs (30d)
- 10
Description
- [x] I have read through the manual page (`man fzf`)
- [x] I have the latest version of fzf
- [x] I have searched through the existing issues
## Info
- OS
- [x] Linux
- [ ] Mac OS X
- [ ] Windows
- [ ] Etc.
- Shell
- [x] bash
- [ ] zsh
- [ ] fish
## Problem / Steps to reproduce
bash `ctrl-o` `operate-and-get-next` stops working once I source `source ~/.fzf.bash` which is auto generated by fzf and replaces the default `ctrl-r` by the `__fzf_history__` function.
fzf `ctrl-r` behavior
1. `bash --noprofile --norc`
2. `source ~/.fzf.bash`
2. `export FZF_CTRL_R_OPTS="--bind=ctrl-o:accept"`, I don't see an `accept-and-execute` event, and `execute(...)` isn't what I want either.
2. `cd ~`
3. `ls`
4. press `ctrl-r`
5. find `cd ~` command
6. press `ctrl-o`, notice fzf exits and command line is populated with `cd ~`, but no execution happens.
7. press `ctrl-o` again, notice it executes `cd ~`, then populates `cd ~` again.
for comparison, here is vanilla bash `ctrl-r` behavior
1. `bash --noprofile --norc`
2. `cd ~`
3. `ls`
4. press `ctrl-r`
5. find `cd ~` command
6. press `ctrl-o`, notice the history search exits and the command is executed, and `ls` is auto populated, ready for execution.
7. press `ctrl-o` will execute `ls` and further chain up remaining next commands, eventualy giving a walking through previous sequence effect. this works even when I modify the commands (except the first one found in history which has to be executed as is by `ctrl-o`).
is there anyway to keep bash original `ctrl-o` behavior? I do like fzf to search history, but the `ctrl-o` auto sequencing behavior is very useful, e.g., in edit-compile-run cycles. thanks.
for reference, here is some explanation about bash behavior, I found it on http://web.mit.edu/gnu/doc/html/features_7.html
```
operate-and-get-next (C-o)
Accept the current line for execution and fetch the next line relative to the current line from the history for editing. Any argument is ignored.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the generated ~/.fzf.bash integration and the __fzf_history__ function, then reproduce the listed bash history sequence using FZF_CTRL_R_OPTS="--bind=ctrl-o:accept". Done means fzf preserves bash's ctrl-o behavior: executing the selected command and preparing the next history command for execution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100