junegunn/fzf
Filter mode
--filter QUERY (or -f QUERY) makes fzf scan its input, apply the query, print every match in score order, and exit — no UI involved. This is the canonical way to use fzf inside scripts.
Behavior
$ printf 'foo\nbar\nbaz\nfox\n' | fzf -f 'fo'
foo
fox- Reads from stdin (or
FZF_DEFAULT_COMMANDif stdin is a TTY) just like the interactive mode. - Applies the same matching pipeline as the interactive mode: extended-search syntax, normalization, scheme, scoring.
- Prints matches to stdout in descending score order, with tiebreakers from
--tiebreak. - Exits with code
0if at least one item matched,1(ExitNoMatch) otherwise.
Streaming filter
When fzf can stream — which means: --no-sort is set, --no-tac is set, --sync is not, and --bench is not — Run in src/core.go skips chunk-list snapshotting entirely and runs the matcher inline as items arrive:
// Filtering mode (in Run)
if streamingFilter {
reader := NewReader(func(runes []byte) bool {
item := Item{}
if chunkList.trans(&item, runes) {
...
if result, _, _ := pattern.MatchItem(&item, false, slab); result.item != nil {
opts.Printer(transformer(&item))
found = true
}
}
return false
}, eventBox, executor, opts.ReadZero, false)
reader.ReadSource(...)
}Streaming mode is what makes cat huge-log | fzf -f foo --no-sort start producing output immediately.
When sorting is required, fzf falls back to the standard scan-and-sort path: read everything into the chunk list, snapshot it, run a parallel scan via Matcher.scan, print the merger.
Useful flags
| Flag | Effect |
| --------------------- | ------------------------------------------------------------------ | ----------------------------- |
| --no-sort | Stream output as matches are found. |
| --print-query | Print the query as the first output line. Useful when chaining. |
| --exit-0 | Exit immediately with ExitNoMatch if there are no matches. |
| --select-1 | Auto-accept if exactly one item matches (interactive mode mostly). |
| -d, --delimiter=STR | Field delimiter (regex) for --nth / --with-nth. |
| -n, --nth=... | Restrict matching to specific fields. |
| --with-nth=... | Transform what is matched against. |
| --accept-nth=... | Choose which fields to print. |
| --tiebreak=... | Comma-separated tiebreak criteria. |
| --scheme=path | history | Apply a tuned scoring scheme. |
| --ansi | Honor ANSI escape sequences in input. |
--bench
--bench DURATION (e.g. --bench=2s) runs the matcher in a tight loop on the same input for the given duration and prints timing statistics. It's a microbenchmark for the matcher, not a real filter; the rest of the pipeline is bypassed.
Where it lives
| Concern | File |
|---|---|
| Filter branch | src/core.go (after if opts.Filter != nil) |
| Streaming filter | src/core.go (streamingFilter block) |
| Tests | test/test_filter.rb |
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.