The Fuzzy Finder โ Interactive Search for Everything at the CLI
fzf is a general-purpose command-line fuzzy finder. It reads a list of items from stdin, lets you interactively filter them by typing, and outputs your selection to stdout. That's it โ and that simplicity is exactly what makes it powerful.
Anything that produces a list is a candidate: files, processes, command history, git commits, log entries, hostnames, systemd units, docker containers. If you can pipe it, you can fzf it.
The AI angle: As AI tools generate more output โ logs of AI interactions, lists of generated files, fabric pattern outputs, sgpt history โ fzf becomes the navigation layer that keeps you from drowning in text. It's the retrieval half of the AI workflow.
dnf install fzf
Available in EPEL. Enable EPEL first if needed:
dnf install epel-release
apt install fzf
Or install from git for the latest version:
git clone --depth 1 \ https://github.com/junegunn/fzf.git \ ~/.fzf ~/.fzf/install
The real power comes from shell integration. Add to your ~/.bashrc:
# fzf shell integration source /usr/share/fzf/shell/key-bindings.bash source /usr/share/fzf/shell/completion.bash
Or if installed from git:
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
Then reload: source ~/.bashrc
Ctrl+R โ fuzzy search command history (replaces default reverse-i-search)Ctrl+T โ fuzzy search files, paste selected path at cursorAlt+C โ fuzzy search directories, cd into selection
# Fuzzy search all files under current directory
fzf
# Preview file content as you select
fzf --preview 'cat {}'
# Multi-select with Tab, output all selections
fzf --multi
# Search running processes ps aux | fzf # Search systemd units systemctl list-units | fzf # Search your command history directly history | fzf
# Open selected file in vim
vim $(fzf)
# Kill selected process
kill $(ps aux | fzf | awk '{print $2}')
# SSH to selected host from your known_hosts
ssh $(grep -oE '^[^ ]+' ~/.ssh/known_hosts | fzf)
Pipe log output through fzf for interactive filtering โ far faster than grep when you're not sure exactly what you're looking for.
# Search today's syslog interactively
tail -1000 /var/log/messages | fzf
# Search journalctl output
journalctl -n 2000 | fzf
# Search with live preview of surrounding context
journalctl --no-pager | fzf --preview 'echo {}'
Navigate large directory trees without remembering exact paths.
# Find and edit any config file under /etc vim $(find /etc -name "*.conf" 2>/dev/null | fzf) # Find and tail any log file tail -f $(find /var/log -type f | fzf) # Find any file in the web tree vim $(find /var/www/html -name "*.html" | fzf)
Interactively select units to manage โ no more tab-completing through hundreds of unit names.
# Interactively restart a service
systemctl restart $(systemctl list-units --type=service \
--state=running | fzf | awk '{print $1}')
# Check status of any unit
systemctl status $(systemctl list-units \
| fzf | awk '{print $1}')
Navigate branches, commits, and stashes interactively.
# Checkout any branch interactively
git checkout $(git branch -a | fzf | tr -d ' ')
# Fuzzy search git log, preview diff
git log --oneline | fzf \
--preview 'git show --stat $(echo {} | cut -d" " -f1)'
# Interactively add files to staging
git diff --name-only | fzf --multi \
| xargs git add
Keep a host list and fuzzy-select your SSH target โ useful when managing dozens of servers.
# SSH to any host in known_hosts ssh $(grep -oE '^[^, ]+' ~/.ssh/known_hosts \ | sort -u | fzf) # Or maintain a hosts file and fzf it ssh $(cat ~/.my_hosts | fzf)
Ctrl+R with fzf replaces the default bash reverse search with something dramatically better โ full fuzzy matching across your entire history.
# After shell integration, just press: # Ctrl+R โ opens full history in fzf # Type any fragment of the command you remember # Enter to execute, Ctrl+E to edit first
This alone is worth installing fzf. If you've ever half-remembered a complex pipeline from three weeks ago, you know why.
fzf pairs naturally with the other AI tools in this section โ it's the navigation and retrieval layer for AI-generated output.
When fabric generates summaries or reports, pipe them through fzf for interactive review.
# List and select from available fabric patterns
ls ~/.config/fabric/patterns | fzf \
| xargs -I{} fabric --pattern {}
# Search through fabric output saved to files
ls ~/fabric-output/*.md | fzf \
--preview 'cat {}'
sgpt can maintain chat history. Use fzf to search previous AI interactions.
# Search sgpt chat history files
ls ~/.config/shell_gpt/chat_cache/ | fzf \
--preview 'cat ~/.config/shell_gpt/chat_cache/{}'
When you've built up a library of AI-generated reference files (like Craig's Linux command library), fzf is the fastest way to get to the right file.
# Find any HTML doc in the LessonPlans tree
vim $(find /var/www/html/LessonPlans \
-name "*.html" | fzf \
--preview 'head -30 {}')
| Option | Effect |
|---|---|
--multi | Enable multi-select with Tab key |
--preview 'cmd {}' | Show preview of each item as you navigate |
--height 40% | Use only part of the terminal height |
--reverse | Show list top-to-bottom instead of bottom-to-top |
--query 'initial' | Start with a pre-filled search query |
--select-1 | Auto-select if only one match |
--exit-0 | Exit if no matches (for scripting) |
--filter 'str' | Non-interactive filter mode โ useful in scripts |
Add to ~/.bashrc to set defaults:
# Default options for all fzf invocations
export FZF_DEFAULT_OPTS='--height 40% --reverse --border'
# Use fd or find for file search (fd is faster)
export FZF_DEFAULT_COMMAND='find . -type f'
# Ctrl+T file search options
export FZF_CTRL_T_OPTS='--preview "cat {}" --preview-window=right:50%'
# Ctrl+R history search options
export FZF_CTRL_R_OPTS='--reverse --preview "echo {}" --preview-window=down:3'
| Aspect | Reality |
|---|---|
| Learning curve | Low โ basic use is immediate. Advanced scripting takes an hour of reading. |
| Daily value | High โ Ctrl+R alone changes how you use the shell. The rest is gravy. |
| Scripting integration | Excellent โ stdin/stdout design means it drops into any pipeline. |
| Dependencies | Minimal โ single binary, no runtime dependencies. |
| Performance | Fast โ handles millions of lines without slowing down. |
| AI-specific features | Indirect โ not an AI tool itself, but pairs well with AI tool output. |
| Replaces | Ctrl+R, tab completion hunting, repeated grep iterations |
| Doesn't replace | grep for non-interactive scripts, find for complex queries |