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

Always execute preview command if {q} is in the template

Even when {q} is empty. Because, why not?

While this can be seen as a breaking change, there is an easy workaround
to keep the old behavior.

    # This will show // even when the query is empty
    : | fzf --preview 'echo /{q}/'

    # But if you don't want it,
    : | fzf --preview '[ -n {q} ] || exit; echo /{q}/'

Close #2759
This commit is contained in:
Junegunn Choi
2022-12-30 09:57:10 +09:00
parent 6c37177cf5
commit d649f5d826
4 changed files with 18 additions and 7 deletions

View File

@@ -68,12 +68,22 @@ CHANGELOG
# Can only type numbers
fzf --bind 'change:transform-query(sed 's/[^0-9]//g' <<< {q})'
```
- Improvements
- `put` action can optionally take an argument string
```sh
# a will put 'alpha' on the prompt, ctrl-b will put 'bravo'
fzf --bind 'a:put+put(lpha),ctrl-b:put(bravo)'
```
- Behavior changes
- fzf will always execute the preview command if the command template
contains `{q}` even when it's empty. If you prefer the old behavior,
you'll have to check if `{q}` is empty in your command.
```sh
# This will show // even when the query is empty
: | fzf --preview 'echo /{q}/'
# But if you don't want it,
: | fzf --preview '[ -n {q} ] || exit; echo /{q}/'
```
- `double-click` will behave the same as `enter` unless otherwise specified,
so you don't have to repeat the same action twice in `--bind` in most cases.
```sh