fzf Plugin
Overview
The fzf plugin provides a command-line fuzzy finder. An interactive Unix filter that can be used with any list: files, command history, processes, hostnames, bookmarks, git commits, and more.
What is fzf?
fzf is a general-purpose command-line fuzzy finder. It's an interactive Unix filter that works with any command that produces output. Search through lists with a fuzzy matching algorithm.
Quick Start
1. Install fzf
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
# or with Homebrew
brew install fzf
2. Basic usage
# Find files
find . -type f | fzf
# Search git branches
git branch | fzf
# Search command history
history | fzf
3. Verify installation
sc fzf self version
Common Use Cases
File Selection
# Interactive file selection
find . -type f | fzf
# With preview
find . -type f | fzf --preview 'cat {}'
Git Integration
# Select branch to checkout
git branch | fzf | xargs git checkout
# Select commit to view
git log --oneline | fzf
Command History
# Search and execute from history
history | fzf +s | tac | sed 's/ *[0-9]* *//' | sh
Process Management
# Select and kill process
ps aux | fzf | awk '{print $2}' | xargs kill
Keybindings
Ctrl+J/Ctrl+K: Move down/upEnter: SelectEsc: CancelCtrl+T: Toggle selectionCtrl+R: Toggle sortCtrl+A: Select allCtrl+D: Deselect all
Useful Commands
sc fzf files select- Interactive file selectionsc fzf files select --multi- Enable multi-selectsc fzf files select --preview 'cat {}'- With previewsc fzf history search- Search command history
Shell Integration
Add to your shell config for better integration:
# Use fzf for Ctrl+T (file search)
source ~/.fzf/shell/key-bindings.bash
# Use fzf for Ctrl+R (history search)
source ~/.fzf/shell/key-bindings.bash
Options
--height: Set height (e.g., 40%)--multi: Enable multi-select with Tab--preview: Show preview window--query: Set initial query--filter: Filter by exact match--exact: Enable exact matching
Requirements
- Terminal with color support
- Unix-like system
Tips
- Use
--multiwith Tab to select multiple items - Add
--previewfor file previews - Pipe any command output into fzf
- Use with
xargsto execute on selection
Resources
- GitHub: https://github.com/junegunn/fzf