๐Ÿ” fzf

The Fuzzy Finder โ€” Interactive Search for Everything at the CLI

aider curl fabric fzf gh Copilot jq ollama ripgrep sgpt tmux

What Is fzf?

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.

"fzf doesn't do one thing well. It does one thing perfectly โ€” and that one thing plugs into everything else. In a Unix environment, that's the highest compliment you can pay a tool."

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.

๐Ÿ“ฆ Installation

RHEL / AlmaLinux / Rocky

dnf install fzf

Available in EPEL. Enable EPEL first if needed:

dnf install epel-release

Debian / Ubuntu

apt install fzf

Or install from git for the latest version:

git clone --depth 1 \
  https://github.com/junegunn/fzf.git \
  ~/.fzf
~/.fzf/install

Shell Integration

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

Three key bindings you get from shell integration:
Ctrl+R โ€” fuzzy search command history (replaces default reverse-i-search)
Ctrl+T โ€” fuzzy search files, paste selected path at cursor
Alt+C โ€” fuzzy search directories, cd into selection

โŒจ๏ธ Basic Usage

Standalone

# 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

Piping Input

# Search running processes
ps aux | fzf

# Search systemd units
systemctl list-units | fzf

# Search your command history directly
history | fzf

Using the Selection

# 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)

๐Ÿง SysAdmin Use Cases

๐Ÿ” Interactive Log Search

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 {}'

๐Ÿ“ File Navigation

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)

โš™๏ธ systemd Unit Management

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}')

๐ŸŒฟ Git Workflow

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

๐Ÿ”‘ SSH Host Selection

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)

๐Ÿ“œ Command History Power Search

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 + AI Tools

fzf pairs naturally with the other AI tools in this section โ€” it's the navigation and retrieval layer for AI-generated output.

๐Ÿงต Navigate fabric Pattern 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 {}'

๐Ÿš Navigate sgpt Shell History

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/{}'

๐Ÿ“‚ Navigate AI-Generated Documentation

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 {}')

โš™๏ธ Useful Options & Configuration

Key Options

OptionEffect
--multiEnable multi-select with Tab key
--preview 'cmd {}'Show preview of each item as you navigate
--height 40%Use only part of the terminal height
--reverseShow list top-to-bottom instead of bottom-to-top
--query 'initial'Start with a pre-filled search query
--select-1Auto-select if only one match
--exit-0Exit if no matches (for scripting)
--filter 'str'Non-interactive filter mode โ€” useful in scripts

Environment Configuration

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'

๐Ÿ“Š Honest Assessment

AspectReality
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
Bottom line for SysAdmins: fzf is in the category of tools you install once and then can't imagine working without. The shell history integration alone justifies the five-minute install. Everything else is a bonus.

๐Ÿ”— Related Tools in This Section