Configs2026年4月11日·1 分钟阅读

fzf — Blazing Fast Command-Line Fuzzy Finder

fzf is a general-purpose command-line fuzzy finder written in Go. Blazing fast, portable, and composable with any list-producing command. Interactive picker for files, commands, history, git branches, processes, and more.

AI
AI Open Source · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

# Install
brew install fzf                        # macOS
sudo apt install fzf                    # Debian/Ubuntu
scoop install fzf                       # Windows
git clone https://github.com/junegunn/fzf ~/.fzf && ~/.fzf/install

Common patterns:

# Interactive file picker
vim $(fzf)

# Fuzzy history search
history | fzf

# Git branch picker
git checkout $(git branch | fzf)

# Kill process by name
kill -9 $(ps -ef | fzf | awk "{print \$2}")

# Preview files while selecting
fzf --preview "bat --color=always {}"

Key bindings (after source ~/.fzf.zsh):

  • Ctrl+T — paste selected files/dirs
  • Ctrl+R — search history
  • Alt+C — cd into selected directory
介绍

fzf is a general-purpose command-line fuzzy finder written in Go by Junegunn Choi. Portable, dependency-free, and blazingly fast — it uses a smart fuzzy-matching algorithm that ranks results intelligently. Works as an interactive Unix filter for any list-producing command.

What fzf Does

  • Interactive filter — pipe any list, select one or many
  • Fuzzy matching — type partial letters to narrow down
  • Preview window — show file contents, git diff, commit message
  • Multi-select--multi for selecting multiple items
  • Key bindings — Ctrl+T (files), Ctrl+R (history), Alt+C (dirs)
  • Shell integrations — bash, zsh, fish auto-completions
  • Composable — works with any find, ls, git, ps, history

Architecture

Reads stdin, renders interactive TUI via termios. On Enter, writes selection to stdout. Matching algorithm combines substring match, camelCase boundaries, and path components for intelligent ranking.

Self-Hosting

CLI tool, zero runtime deps.

Key Features

  • Super fast (Go + optimized matcher)
  • Fuzzy matching with smart ranking
  • Preview window
  • Multi-select mode
  • Shell key bindings
  • Works with any input stream
  • Customizable colors and layout
  • Can trigger actions on selection

Comparison

Tool Matching Preview Speed
fzf Fuzzy Yes Fastest
skim (sk) Fuzzy Yes Fast (Rust)
peco Fuzzy No Medium
fzy Fuzzy No Fast (small)
percol Fuzzy Limited Python

常见问题 FAQ

Q: fzf 和 ripgrep 能一起用吗? A: 绝配。rg --files | fzf 在 gitignore 感知的文件列表中模糊匹配。

Q: 怎么配合 tmux? A: fzf 支持 --tmux 选项在浮动 pane 中显示。

Q: 怎么定义 preview? A: fzf --preview "bat --color=always {}" --preview-window=right:60%

来源与致谢 Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产