How to Install and Use fzf in Linux for Interactive Command-Line Fuzzy Filtering and History Search

Navigating large Linux directories, recalling complex shell commands from bash history, and managing Git branches using standard terminal utilities often feels sluggish and disjointed. Typing history | grep <command> or recursively running find requires exact string matching and manual scrolling through hundreds of lines of terminal output.

fzf (Fuzzy Finder) is an open-source, blazingly fast command-line interactive filter written in Go. It can be used with any list: files, command history, processes, hostnames, Git commits, and shell variables. By typing non-consecutive letters, fzf matches target strings with sub-millisecond latency. This guide covers how to install, configure, and integrate fzf into your everyday Linux terminal workflow.

How Fuzzy Searching Works

Unlike standard regex matching (which requires exact substrings), fuzzy matching searches for characters in sequential order regardless of the characters between them. For example, typing pjconf will instantly match:

  • /src/project/settings/config.json
  • /etc/proxy/jwt_config.yaml

This enables muscle-memory navigation without remembering exact folder structures or spelling.

Installing fzf on Linux

Method 1: Direct Git Clone (Recommended for Latest Keybindings)

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

The installer script prompts you to enable auto-completion and keybindings for Bash, Zsh, or Fish. Answer yes (y) to all prompts.

Method 2: Using Distribution Package Managers

# Ubuntu / Debian
sudo apt update && sudo apt install -y fzf

# Fedora / Rocky Linux
sudo dnf install -y fzf

# Arch Linux
sudo pacman -S fzf

Essential Built-In Keybindings

Once installed, fzf binds three transformative shortcuts directly into your shell:

Keybinding Triggered Action Workflow Benefit
Ctrl + R Interactive Shell History Search Type fragments to recall and execute past complex shell commands instantly
Ctrl + T Interactive File & Directory Finder Pastes the selected file path directly at the active cursor command line
Alt + C Fuzzy Change Directory (cd) Fuzzy-filters all subdirectories and immediately changes into the chosen folder

Supercharging Pipes with fzf

One of fzf‘s greatest superpowers is acting as an interactive middleman in standard Unix pipeline workflows:

1. Interactive File Editing

# Fuzzy search files and open the selection in vim/nano
nvim $(fzf)

2. Killing Runaway Processes

# Fuzzy search active processes and kill the selected PID
kill -9 $(ps -ef | fzf | awk '{print $2}')

3. Interactive Git Branch Switching

# Switch to any local git branch with fuzzy selection
git checkout $(git branch | fzf | tr -d ' *')

Configuring Previews with bat

By pairing fzf with the bat syntax-highlighting utility, you can render live code preview windows alongside your fuzzy search results:

# Add to ~/.bashrc or ~/.zshrc
export FZF_DEFAULT_OPTS="--height 50% --layout=reverse --border --preview 'bat --style=numbers --color=always {} 2> /dev/null || cat {}'"

Now, pressing Ctrl + T displays an interactive two-pane split with file contents rendered in real time as you scroll.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.