fzf Cheatsheet

0.57

Fuzzy find everything

Fuzzy finding everything — files, history, processes, and more

Official docs →
Shell integrationsPreview windowCustom patterns

Last updated: 2026-03-29

fzf is a fuzzy finder for your terminal, and once you start using it, you'll wonder how you ever survived without it. Pipe anything into it — file lists, git branches, process IDs, environment variables, literally any line-based input — and fzf gives you an instant, interactive, typo-forgiving search interface. It turns "scroll through 400 lines of output squinting at each one" into "type three characters and you're there."

The beauty of fzf is that it's a Unix filter. It reads lines from stdin, lets you pick one (or many), and writes your selection to stdout. That's it. That simple contract means it plugs into everything. Combine it with find, rg, git, ps, docker, or anything else that produces text, and you've got an interactive selector for free. It's the duct tape of terminal workflows — except it's actually elegant.

This cheatsheet focuses on the patterns you'll use constantly: the core commands, the shell integrations that'll change how you navigate your filesystem, the preview window that makes selections feel luxurious, and the real-world recipes that turn fzf from "neat toy" into "essential infrastructure." If you only learn three things here, make it Ctrl-R, Ctrl-T, and the --preview flag. Everything else is gravy.

Basic Usage

The fundamentals. Most people start here and never realize how deep the rabbit hole goes.

Basic Usage
fzf
Launch fzf with a recursive file list from the current directory
<cmd> | fzf
Pipe any command output into fzf for interactive filtering
fzf --query "str"
Start with a pre-filled search query
fzf --filter "str"
Non-interactive mode — prints matches to stdout and exits
fzf --select-1
Auto-select if there is only one match
fzf --exit-0
Exit immediately if there are no matches
fzf -m
Enable multi-select mode (Tab to toggle selections)
fzf --height 40%
Open fzf inline instead of fullscreen
fzf --reverse
Display the list top-down instead of bottom-up
fzf --exact
Disable fuzzy matching — only show exact substring matches

Search Syntax

fzf's search language is small but surprisingly powerful. You can combine these tokens in a single query.

Search Syntax
sbtrkt
Fuzzy match — characters must appear in order, but not consecutively
'wild
Exact match (prefixed with single quote)
^music
Prefix exact match — must start with "music"
.mp3$
Suffix exact match — must end with ".mp3"
!fire
Inverse exact match — exclude lines containing "fire"
!'.mp3$
Inverse suffix match — exclude lines ending with ".mp3"
foo | bar
OR operator — match lines with "foo" or "bar"

Key Bindings Inside fzf

Once fzf is open, these keys control navigation and selection.

Key Bindings Inside fzf
Ctrl-j / Ctrl-n
Move cursor down
Ctrl-k / Ctrl-p
Move cursor up
Enter
Accept current selection
Tab
Toggle selection in multi-select mode (-m)
Shift-Tab
Deselect in multi-select mode
Ctrl-a
Select all matches (multi-select mode)
Ctrl-d
Deselect all (multi-select mode)
Ctrl-/
Toggle preview window visibility
Ctrl-c / Esc
Cancel and exit fzf
Ctrl-l
Clear the search query

Shell Integrations

These are the three bindings that make fzf feel like a superpower. They wire directly into your shell and work out of the box after installation.

Shell Integrations
Ctrl-R
Search shell command history — the single best fzf feature
Ctrl-T
Find files and paste the selected path into your command line
Alt-C
Fuzzy-find a directory and cd into it immediately
**<Tab>
Trigger fzf completion (e.g., vim **<Tab>, cd **<Tab>)
kill **<Tab>
Fuzzy-find a process to kill via completion
ssh **<Tab>
Fuzzy-find a host from known_hosts / ssh config

Preview Window

The preview window turns fzf from a selector into a full browser. You can preview files, syntax-highlighted code, images, git diffs — anything you can pipe through a command.

Preview Window
--preview "cat {}"
Show file contents in a preview pane
--preview "bat --color=always {}"
Syntax-highlighted preview with bat (the gold standard)
--preview-window right:60%
Place preview on the right, taking 60% of width
--preview-window up:50%:wrap
Place preview on top with line wrapping
--preview-window hidden
Start with preview hidden, toggle with Ctrl-/
--bind "ctrl-u:preview-half-page-up"
Bind Ctrl-u to scroll up in the preview
--bind "ctrl-d:preview-half-page-down"
Bind Ctrl-d to scroll down in the preview

Common Patterns

These are the copy-paste recipes that make fzf indispensable. Each one solves a real problem you've probably hit this week.

Process Management
kill -9 $(ps aux | fzf | awk '{print $2}')
Fuzzy-find and kill a process
ps aux | fzf -m | awk '{print $2}' | xargs kill
Kill multiple processes at once
Git Workflows
git branch | fzf | xargs git switch
Fuzzy-find and switch to a git branch
git log --oneline | fzf --preview "git show {1}"
Browse commits with diff preview
git diff --name-only | fzf --preview "git diff {}"
Browse changed files with inline diff
git stash list | fzf | cut -d: -f1 | xargs git stash pop
Pick a stash to pop interactively
Docker
docker ps | fzf | awk '{print $1}' | xargs docker stop
Fuzzy-find and stop a running container
docker images | fzf | awk '{print $3}' | xargs docker rmi
Fuzzy-find and remove an image
docker logs -f $(docker ps | fzf | awk '{print $1}')
Tail logs from a selected container
File & Directory Navigation
vim $(fzf)
Open a fuzzy-found file in your editor
cd $(fd -t d | fzf)
Fuzzy-find a directory and cd into it
rg --files | fzf --preview "bat --color=always {}"
Browse project files with syntax-highlighted preview
rg -l "pattern" | fzf --preview "rg --color=always pattern {}"
Find files matching a pattern, preview matches in context

Tips

Set FZF_DEFAULT_COMMAND to use fd or rg instead of the default find. They're faster, respect .gitignore, and skip junk like node_modules automatically. Try export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git' in your shell profile.

Customize the shell integrations independently with FZF_CTRL_T_COMMAND, FZF_CTRL_R_OPTS, and FZF_ALT_C_COMMAND. For example, set FZF_ALT_C_COMMAND='fd --type d' so Alt-C uses fd for blazing-fast directory search and automatically ignores .gitignore entries.

Put your default fzf options in FZF_DEFAULT_OPTS so they apply everywhere. A solid starting point: export FZF_DEFAULT_OPTS='--height 40% --reverse --border --preview-window right:50%:wrap'. This gives you a compact, top-down layout with a preview pane on every invocation.

Use --bind to add custom actions. For instance, --bind 'ctrl-y:execute-silent(echo {} | pbcopy)' copies the current selection to your clipboard without leaving fzf. You can bind any key to execute, reload, preview, or change fzf's behavior on the fly.

The --preview command has access to placeholders: {} is the full line, {1} is the first field, {q} is the current query, and {n} is the line number. These let you build surprisingly sophisticated previews without writing a wrapper script.

Chain fzf with --header to give your custom scripts user-friendly context. Something like git branch | fzf --header "Switch to branch:" makes throwaway scripts feel polished. Pair it with --prompt to customize the search prompt text too.

In tmux, fzf can open in a popup instead of inline. Use fzf-tmux -p 80%,60% to launch fzf in a centered floating popup window. It's slick, stays out of your main pane, and disappears when you're done. Once you try it, inline fzf feels cramped.

Related Tools