m/fzf
1
0
mirror of https://github.com/junegunn/fzf.git synced 2025-11-19 17:13:42 -05:00

Add transform-query(...) action

Test case authored by @SpicyLemon

Close #1930
Close #2465
Close #2559
Close #2509 (e.g. fzf --bind 'space:transform-query:printf %s%s {q} {}')
This commit is contained in:
Junegunn Choi
2022-12-28 00:05:31 +09:00
parent 4dbe45640a
commit 36d2bb332b
5 changed files with 51 additions and 7 deletions

View File

@@ -31,7 +31,23 @@ CHANGELOG
# Both actions respect --layout option
seq 10 | fzf --multi --bind ctrl-n:next-selected,ctrl-p:prev-selected --layout reverse
```
- Added `change-query(...)` action
- Added `change-query(...)` action that simply changes the query string to the
given static string. This can be useful when used with `--listen`.
```sh
curl localhost:6266 -d "change-query:$(date)"
```
- Added `transform-query(...)` action for transforming the query string using
an external command
```sh
# Press space to convert the query to uppercase letters
fzf --bind 'space:transform-query(tr [:lower:] [:upper:] <<< {q})'
# Bind it to 'change' event for automatic conversion
fzf --bind 'change:transform-query(tr [:lower:] [:upper:] <<< {q})'
# Can only type numbers
fzf --bind 'change:transform-query(sed 's/[^0-9]//g' <<< {q})'
```
- `put` action can optionally take an argument string
```sh
# a will put 'alpha' on the prompt, ctrl-b will put 'bravo'