As a developer, wasting minutes searching for files in a large codebase adds up fast. fzf (fuzzy finder) is a lightning-fast command-line tool that lets you instantly find and select files using fuzzy matching—no exact paths needed. In this guide, you’ll learn how to install, configure, and master fzf to transform your terminal workflow.
What is fzf?
fzf is a versatile fuzzy finder for the terminal, designed to help developers quickly search through files, commands, or process lists. Unlike traditional search tools, fzf uses incremental fuzzy matching, allowing you to type partial patterns and see real-time results—making it ideal for navigating complex projects.
Installing fzf Across Platforms
Installing fzf is straightforward on most systems. Here’s how to get started:
- macOS: Use Homebrew:
brew install fzf - Linux (Debian/Ubuntu): Install via APT:
sudo apt-get install fzf, or build from source withgit clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf && ~/.fzf/install - Windows (WSL): Follow the Linux instructions, or use
scoop install fzfif you prefer Scoop package manager
After installation, run the setup script to enable shell integration and keybindings. For example, in bash: ~/.fzf/install (if installed manually), or follow the prompts from your package manager.
Basic File Search with fzf
Once installed, use fzf to search files with simple commands. Here are common workflows:
- Search current directory:
find . | fzf - Search specific file types:
find . -name '*.js' | fzf - Combine with git for versioned files:
git ls-files | fzf
As you type, fzf dynamically filters results. For example, typing app/js will match src/app/main.js even without exact path characters.
Shell Integration for Seamless Workflow
Integrating fzf into your shell boosts productivity significantly. Add these lines to your .bashrc or .zshrc:
# For bash
source /usr/share/fzf/key-bindings.bash
source /usr/share/fzf/completion.bash
# For zsh
source /usr/share/fzf/key-bindings.zsh
source /usr/share/fzf/completion.zsh
After reloading your shell, you gain powerful shortcuts:
- Ctrl+R: Fuzzy search command history
- Alt+C: Fuzzy cd to directory
- Ctrl+T: Fuzzy file selection for pasting paths
These shortcuts let you navigate or execute commands without typing full paths—saving seconds that compound into hours over time.
Advanced Features: Previews and Customization
fzf’s preview pane shows file contents or metadata as you navigate. Enable it with:
fzf --preview 'bat --style=numbers --color=always {}'
This uses bat (a cat replacement) to display syntax-highlighted code. Customize the preview command for your needs—like using head -50 {} for quick text previews.
For even more control, define a custom preview script in your .fzfrc file. For example:
export FZF_DEFAULT_OPTS='--preview "bat --style=numbers --color=always {}" --height 40%'
This ensures previews work globally with minimal setup.
Integrating fzf with Developer Tools
Combine fzf with other CLI tools for powerful workflows:
- With ripgrep:
rg --files | fzf | xargs codeto open files in VS Code - With git:
git log --pretty=format:%h | fzf | xargs git showto view specific commits - With ssh:
cat ~/.ssh/config | grep Host | cut -d ' ' -f2 | fzfto select server aliases
These integrations let you chain tools together, creating custom pipelines that adapt to your workflow.
Conclusion
fzf is a game-changer for terminal productivity, turning tedious file searches into intuitive, rapid actions. By mastering its fuzzy matching, shell integrations, and preview features, you’ll reclaim hours of wasted time. Start small—try Ctrl+T to paste file paths or find . | fzf to browse your project—and build from there. The result? A faster, more focused development workflow that scales with your projects.