Custom Components Preview
Accordion 🪗
Use accordions for progressive disclosure—content that is useful but not immediately necessary for the main flow.
- FAQs: Question & Answer sections.
- Long Outputs/Logs: Error stack traces or raw JSON responses that take up too much vertical space.
- Deep Dives/Tangents: Technical background info that is “nice to know” but strictly “need to know.”
- Spoilers: Solutions to exercises or plot points.
When you execute the pipeline, fd begins scanning immediately. Crucially, fzf doesn’t block waiting for fd to finish.
It uses a streaming architecture: as soon as fd emits a path to stdout, fzf grabs it from stdin and populates the list in real-time. This is why the UI loads instantly, even while fd is still churning through thousands of files in the background.
The --preview flag transforms fzf from a simple text filter into a command orchestrator.
- Dynamic Substitution The
{}placeholder is the key. As you traverse the list,fzfdynamically swaps{}with the currently highlighted path (e.g.,packages/ui). - Subprocess Execution For every cursor move,
fzfspawns a temporary shell process to execute the constructed command (eza ... packages/ui). - ANSI Passthrough Since we forced
--color=always,ezaoutputs raw ANSI escape codes.fzfacts as a mini terminal emulator here, capturing those codes and faithfully rendering the colors and icons in the side panel.
You might wonder: “If I scroll down quickly, will it spawn 50 instances of eza in a second?”
Smartly, fzf employs a debounce mechanism. If you scroll fast, it holds off on spawning the preview command until the cursor settles for a fraction of a second. It also aggressively kills any stale eza processes from previous selections to prevent your CPU from melting.
Once you find the directory you need and press Enter, fzf terminates, closes the eza preview, and prints the selected path to standard output.
This is the essence of the Unix philosophy. Because fzf sends clean text to stdout, you can compose it with other commands—like jumping into that directory automatically:
cd $(fd --type directory | fzf ...)
Custom Components Preview