[Bug] Can't use `fzf` non-interactively: the option `-f` doesn't work as expected.
anasouardini opened this issue · 4 comments
Checklist
- I have read through the manual page (
man fzf
) - I have searched through the existing issues
- For bug reports, I have checked if the bug is reproducible in the latest version of fzf
Output of fzf --version
0.38.0 (debian)
OS
- Linux
- macOS
- Windows
- Etc.
Shell
- bash
- zsh
- fish
Problem / Steps to reproduce
I want to use fzf
in a non-interactive mode, and from the man
page it seems like the options -f
and +s
are going to make fzf
act like grep
which what I want, but when I use those options, fzf
just exits.
My goal is to select one option even if the query is still vague (doesn't filter down to only one option).
If I'm not mistaken this command should work just find: fzf -1 -0 -f +s --query="r"
I suspect the option -f
to be causing the issue:
-q, --query=STR Start the finder with the given query
-f, --filter=STR Filter mode. Do not start interactive finder.
--filter
(or -f
) should be followed by a query string. In -f +s
case, +s
is recognized as the query string. i.e. equivalent to --filter=+s
. So you should remove --query
and do fzf -1 -0 +s --filter="r"
or fzf -1 -0 -f "r" +s
fzf +s --filter="r"
or fzf -f "r" +s
instead.
I missed to mention that -1
and -0
are not compatible with --filter
but with --query
.
-1, --select-1
If there is only one match for the initial query (--query), do not start interactive finder and automatically select the only match
-0, --exit-0
If there is no match for the initial query (--query), do not start interactive finder and exit immediately
So you should try something like fzf -f "r" +s | head -1
instead.
Hmm, I just realized there is a critical bug in the streaming filter mode (i.e. --no-sort --filter=something
) since fzf 0.47.0.
Thank you, that satisfies my question.