Fundamentals 8 min read

Boost Your Command-Line Efficiency with fzf: Install, Features & Advanced Usage

This guide introduces the open‑source fuzzy finder fzf, explains its key features, shows how to install it across platforms, and provides practical examples—including basic pipelines, shell shortcuts, and preview‑enhanced commands—to dramatically speed up everyday terminal workflows.

macrozheng
macrozheng
macrozheng
Boost Your Command-Line Efficiency with fzf: Install, Features & Advanced Usage

Project Overview

fzf is a general‑purpose command‑line fuzzy finder written in Go. It runs on Unix/Linux, macOS and Windows and can turn any list—files, command history, processes, hostnames, Git branches, etc.—into an interactive, filterable UI.

Key Features

Interactive fuzzy filtering : type any fragment and fzf matches the whole string without needing the exact spelling.

Works on any list : accepts standard input such as file names, Git branches, process tables, etc.

Lightweight & portable : distributed as a single binary for many platforms.

Shell and editor integration : provides integration scripts for Bash, Zsh, Fish and plugins for Vim/Neovim.

Highly customizable : environment variables, key bindings and command‑line options control preview windows, layout, colors and more.

Advanced modes : multi‑selection ( -m), real‑time preview ( --preview), layout adjustments ( --height, --layout), and custom actions via --bind.

Quick Installation

Install the pre‑built binary with the package manager of your platform:

brew install fzf          # macOS
sudo apt install fzf    # Debian/Ubuntu
sudo dnf install fzf    # Fedora
sudo pacman -S fzf      # Arch

On Windows use Chocolatey or Scoop (full experience is best inside WSL):

choco install fzf
scoop install fzf

Or clone the official repository and run the installer script:

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install

The installer will ask whether to enable the default key bindings (Ctrl‑T, Ctrl‑R, Alt‑C) and to add shell completion.

Basic Pipeline Usage

fzf reads from standard input, so any command that produces text can be piped into it:

# Open a file selected from the current directory
vim $(fzf)

# Switch Git branches interactively
git branch | fzf | cut -c 3- | xargs git checkout

# Kill a process chosen from the process list
ps -ef | fzf | awk '{print $2}' | xargs kill

Shell Shortcuts (Recommended)

Ctrl+T

: recursively search files and directories and paste the selected path at the cursor. Ctrl+R: fuzzy search of command history with a full list of matches. Alt+C: interactively change to a selected directory.

Advanced Usage Examples

Git branch switch with preview – shows the last ten commits of each branch in a side panel:

git branch | fzf \
    --preview 'git log --oneline --graph -n 10 {-1}' \
    --height 40% --layout=reverse | cut -c 3- | xargs git checkout

Explanation: --preview runs the given command for each line; {-1} expands to the current line (the branch name). --height 40% limits the UI height to 40 % of the terminal. --layout=reverse places the prompt at the bottom, which is convenient for preview panes.

Using the become action to replace the default command substitution and avoid issues with spaces or empty selections:

# Open the selected file directly with vim
fzf --bind 'enter:become(vim {})'

# Enable multi‑selection and open all chosen files
fzf -m --bind 'enter:become(vim {+})'

In the first command, pressing Enter replaces the fzf process with vim and passes the selected entry ( {}) as an argument. The second command uses -m for multi‑select and {+} expands to a space‑separated list of all selected items.

Conclusion

fzf is not a replacement for tools such as find or grep. Instead, it acts as an interactive enhancement layer that can be placed anywhere a list of strings is produced, turning linear filtering into a fast, visual experience.

Project Repository

Official GitHub repository: https://github.com/junegunn/fzf

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxmacOScommand-lineshell integrationfzffuzzy finder
macrozheng
Written by

macrozheng

Dedicated to Java tech sharing and dissecting top open-source projects. Topics include Spring Boot, Spring Cloud, Docker, Kubernetes and more. Author’s GitHub project “mall” has 50K+ stars.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.