Context and Integration Without Losing the Core
A selected row is often only the beginning of a useful terminal action. The person may need to see the matching file line, preserve an identifier hidden inside a formatted record, return to the list after an inspection, or hand the choice to an editor or shell without breaking its syntax. This chapter focuses on how fzf adds that context and reaches different interfaces while keeping the same source–selector–consumer contract. The practical judgment is to add only the preview, transformation, execution mode, and adapter behavior that the data and destination can actually support.
Context without changing the record
A preview is fzf's most direct way to add meaning to a candidate. The candidate remains in the list; an external command receives the current item, and its output appears in a separate preview window. For a file list, that command might show contents. For a search result, it might open the file at the matching line. For a process or pod, it might show a detail view or a log. The preview is therefore contextual evidence alongside the selection, not a second candidate source.
That distinction keeps the producer's responsibility intact. A file producer still decides which paths enter the list. fzf still decides which path has focus. The preview command interprets that path for the person's inspection. If the candidate is instead a process row or a number, a file-oriented preview is the wrong adapter. The project explicitly warns against placing a file-specific preview in global defaults, because fzf is a general-purpose filter and may be fed arbitrary input. A preview belongs with the workflow whose producer guarantees the assumptions it needs.
The preview window can be treated as part of the interaction rather than a fixed decoration. fzf can place it above, below, left, right, or next to the input area; hide it until requested; wrap or follow long output; scroll it; and change its size or layout through a binding. Its command can receive the current record and environment describing the preview's dimensions and position. A long-running preview can render partial output, and a follow mode can keep the view at the end of a growing log. These capabilities make context responsive, but they also mean the child command is part of the latency and resource behavior of the interface.
A structured search result shows how preview and fields work together. Imagine a producer emitting a path, a line number, and matching text separated by colons. The list can search the text field while displaying the path and line number. When the person focuses a row, the preview command can extract the path and line number, show the relevant source, and position the matching line near the middle of the preview. On acceptance, the workflow can open the same path at the same line. fzf did not understand source code; it carried the fields from the producer through a human decision and into two consumers—a preview command and an editor.
Placeholder expressions make that handoff more precise. The ordinary {} placeholder represents the current line and is quoted for use as a command argument. Field expressions such as {1} or {2} select parts of a delimiter-separated record. A + form represents selected items, which matters in multi-select mode, while a * form represents all matched items. Query and ordinal placeholders can carry the current search text or an item's position. For large collections, a file form can place the evaluated list in a temporary file instead of expanding it into a command line whose length may exceed the operating system's argument limit.