Drill: fzf Integration Patterns¶
Goal¶
Use fzf for interactive fuzzy selection in common workflows: file selection, history search, git branches, and process killing.
Setup¶
- Install fzf (
apt install fzf,brew install fzf, orgit clonefrom GitHub) - Shell integration enabled (
source /usr/share/doc/fzf/examples/key-bindings.bashor equivalent)
Commands¶
Basic fuzzy file selection:
Preview files while selecting:
Open a selected file in an editor:
Search command history interactively (Ctrl+R with fzf integration):
Select and checkout a git branch:
Select a git commit to inspect:
Kill a process interactively:
Search and cd into a directory:
Multi-select files (Tab to select, Enter to confirm):
Use fzf with ripgrep for code search:
rg --line-number . | fzf --delimiter=: --preview 'bat --color=always {1} --highlight-line {2}' | cut -d: -f1
What to Look For¶
- fzf filters results as you type with fuzzy matching
- Preview window shows file contents or command output for the highlighted item
- Multi-select mode (--multi) allows selecting multiple items with Tab
- Exit code 130 means the user cancelled (Ctrl+C); handle in scripts
Common Mistakes¶
- Not enabling shell key bindings (Ctrl+R, Ctrl+T, Alt+C)
- Piping binary or very large output into fzf, causing slow rendering
- Forgetting
--multiwhen you need to select more than one item - Not quoting the output of fzf when filenames contain spaces
Cleanup¶
No cleanup needed. fzf is an interactive filter with no side effects.