Skip to content
daniel@MacBookPro:~
Shell & TerminalHow-To September 17, 2026 3 min read

How to Use fzf for Fuzzy Finding in the Shell

A complete walkthrough setting up fzf — a general-purpose fuzzy finder that plugs into history search, file finding, and practically any list-based shell workflow you can pipe text into.

fzf is a general-purpose command-line fuzzy finder — it takes any list of lines on standard input and lets you interactively narrow it down by typing fragments, in any order, rather than an exact match.

Step 1: install fzf

sudo apt install fzf      # Debian/Ubuntu
brew install fzf          # macOS
pkg install fzf           # FreeBSD

Step 2: try it directly on a simple list

find . -type f | fzf

Typing a few characters of a filename narrows the list interactively, matching fuzzy substrings anywhere in each line rather than requiring an exact prefix — selecting a result with Enter prints it to standard output.

Step 3: enable fzf’s shell keybindings

# Bash: in ~/.bashrc
[ -f /usr/share/fzf/key-bindings.bash ] && source /usr/share/fzf/key-bindings.bash

# Zsh: in ~/.zshrc
[ -f /usr/share/fzf/key-bindings.zsh ] && source /usr/share/fzf/key-bindings.zsh

The exact path varies by installation method and OS — the fzf project’s own installer script offers to add these automatically during setup.

Ctrl-R

With fzf’s keybindings enabled, Ctrl-R replaces the shell’s normal reverse history search with fzf’s fuzzy, visually browsable version — considerably more forgiving of typos or approximate memory of a past command than the default incremental search.

Step 5: use fuzzy file finding

Ctrl-T

Inserts a fuzzy file-picker directly at your cursor position in the current command line — useful for quickly inserting a file path into a command without typing or tab-completing the full path manually.

Step 6: use fuzzy directory changing

Alt-C

Fuzzy-searches directories (not files) and cds directly into the one you select — genuinely fast for jumping into a deeply nested project directory without typing or completing the full path.

Step 7: pipe fzf into other commands for custom workflows

git branch | fzf | xargs git checkout

Because fzf is a general-purpose filter reading standard input and writing the selection to standard output, it composes with any command producing a list — git branches, running processes, package names — turning any such list into an interactively searchable one.

Step 8: customize fzf’s appearance and behavior

export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"

FZF_DEFAULT_OPTS controls fzf’s default appearance and behavior across every invocation — useful for setting a consistent height, layout, and preview window configuration without repeating flags on every command.

Step 9: add a preview window for richer context

find . -type f | fzf --preview 'cat {}'

The --preview flag runs a specified command against the currently highlighted item, showing its output in a side pane — genuinely useful for previewing file contents before selecting one from a fuzzy file search.

Why fzf’s generality is its actual strength

Rather than being a feature bolted onto one specific tool, fzf works as a general filter over any list of text — which is exactly why it integrates cleanly with history search, file finding, git workflows, and process management alike, rather than requiring a separate specialized fuzzy-finding tool for each individual use case.