fish: Fixes and improvements to CTRL-R (#4703)
Some checks failed
CodeQL / Analyze (go) (push) Has been cancelled
build / build (push) Has been cancelled
Test fzf on macOS / build (push) Has been cancelled

Fixes:
- Commands with trailing newlines
- Very long previews

Improvements:
- SHIFT-DELETE performance
- Bind ALT-T: cycle command prefix (timestamp, date/time, none)
- Set comment color for prefix
This commit is contained in:
bitraid
2026-03-07 14:36:10 +02:00
committed by Junegunn Choi
parent 2f27a3ede2
commit 3fa0639179
2 changed files with 25 additions and 22 deletions

View File

@@ -506,13 +506,17 @@ the following key bindings in bash, zsh, and fish.
```
- Can be disabled by setting `FZF_CTRL_T_COMMAND` to an empty string when
sourcing the script
- `CTRL-R` - Paste the selected command from history onto the command-line
- `CTRL-R` - Paste the selected command from history onto the command-line. With fish shell, it is possible to select multiple commands.
- If you want to see the commands in chronological order, press `CTRL-R`
again which toggles sorting by relevance
- Press `ALT-R` to toggle "raw" mode where you can see the surrounding items
of a match. In this mode, you can press `CTRL-N` and `CTRL-P` to move
between the matching items only.
- Press `CTRL-/` or `ALT-/` to toggle line wrapping
- Fish shell only:
- Press `SHIFT-DELETE` to delete the selected commands
- Press `ALT-ENTER` to reformat and insert the selected commands
- Press `ALT-T` to cycle through command prefix (timestamp, date/time, none)
- Set `FZF_CTRL_R_OPTS` to pass additional options to fzf
```sh
# CTRL-Y to copy the command into clipboard using pbcopy
@@ -521,6 +525,13 @@ the following key bindings in bash, zsh, and fish.
--color header:italic
--header 'Press CTRL-Y to copy command into clipboard'"
```
```fish
# Fish shell: Set date/time as default prefix
set -gx FZF_CTRL_R_OPTS "--with-nth 1,3.. --bind 'alt-t:change-with-nth(2..|3..|1,3..)'"
# Or display no prefix by default
set -gx FZF_CTRL_R_OPTS "--with-nth 3.. --bind 'alt-t:change-with-nth(2..|1,3..|3..)'"
```
- Can be disabled by setting `FZF_CTRL_R_COMMAND` to an empty string when
sourcing the script
- Custom override via a non-empty `FZF_CTRL_R_COMMAND` is not yet supported and will emit a warning