Drill: fzf Interactive Selection¶
Goal¶
Use fzf's interactive selection features — single select, multi-select, preview, and custom key bindings — to build efficient selection workflows from the command line.
Setup¶
- Install fzf (
apt install fzf,brew install fzf, orgit clonefrom GitHub) - Create test data:
mkdir -p /tmp/fzf-drill && seq 1 100 | xargs -I{} touch /tmp/fzf-drill/file-{}.txt
Commands¶
Single-select a file:
Multi-select files (Tab to toggle, Shift+Tab to untoggle):
Preview file metadata while selecting:
Use a custom prompt and header:
Select and act — delete selected files (with confirmation):
Bind a key to an action (Ctrl+Y to copy selection to clipboard):
Pipe process list through fzf and kill the selected process:
Use fzf with find for recursive directory selection:
What to Look For¶
- Typing filters results fuzzy —
f50matchesfile-50.txt - Tab toggles selection in multi-mode; the count updates in the prompt
- Preview pane updates live as you move through results
- Exit code 0 = selection made, 1 = no match, 130 = user cancelled (Ctrl+C)
Common Mistakes¶
- Forgetting
--multiwhen you need to select more than one item - Not quoting
{}in preview/execute commands when filenames have spaces - Using fzf on binary output or extremely large inputs without filtering first
- Not checking the exit code in scripts — a cancelled fzf should not proceed