FZF ZSH Plugin

December 12, 2025 ยท View on GitHub

This is a plugin for zsh heavily inspired by PatrickF1/fzf.fish.

It's still a work in progress, and has slightly different keybindings.

Keybindings

For git status to work with Ctrl+Alt+S, make sure to disable ixon in your .zshrc:

if [[ $- == *i* ]]; then
  stty -ixon < /dev/tty
fi
KeybindingDescription
Ctrl+Alt+FFile search using fzf
Ctrl+RHistory search using fzf
Alt+cChange directory using fzf
Ctrl+Alt+LGit log search using fzf
Ctrl+Alt+SGit status search using fzf
Ctrl+Alt+GGrep using fzf
Ctrl+VEnvironment variables search using fzf
Ctrl+Alt+WFind a package name using fzf
Ctrl+Alt+BBlame search using fzf

Installation

Antidote

antidote install scaryrawr/fzf.zsh

Oh My Zsh

git clone https://github.com/scaryrawr/fzf.zsh $ZSH_CUSTOM/plugins/fzf

Screenshots

File Search

Image Preview

History Search

Change Directory

Change Directory

Git Log Search

Git Status Search

Environment Variables Search

Find a Package Name

Find a Package Name

Dependencies

Required

Optional

  • chafa - Image preview
  • bat - cat with syntax highlighting
  • eza - Alternative to ls

Customizable Variables

You can customize the behavior of the fzf plugin by setting the following environment variables:

Variable NameDescriptionPassed Argument
FZF_DEFAULT_OPTSDefault options for fzfN/A
FZF_FD_OPTSAdditional options to pass to fdN/A
FZF_PREVIEW_CMDCommand to use for file previewfile path
FZF_GIT_BLAME_PREVIEW_CMDCommand to use for git blame previewfile path
FZF_GIT_COMMIT_PREVIEW_CMDCommand to use for git commit previewcommit
FZF_GIT_LOG_PREVIEW_CMDCommand to use for git log previewcommit
FZF_DIFF_PREVIEW_CMDCommand to use for diff previewdiff
FZF_GIT_STATUS_PREVIEW_CMDCommand to use for git status previewfile path
FZF_PACKAGE_PREVIEW_CMDCommand to use for package previewpackage name

Custom Keybindings

You can override the default keybindings using the FZF_KEYBINDINGS associative array before sourcing the plugin:

# In your .zshrc, before loading the plugin:
typeset -gA FZF_KEYBINDINGS
FZF_KEYBINDINGS[fzf-file-widget]='^F'        # Change file widget to Ctrl+F
FZF_KEYBINDINGS[fzf-history-widget]='^H'     # Change history widget to Ctrl+H
FZF_KEYBINDINGS[fzf-cd-widget]=''            # Disable cd widget (empty string)

Available Widgets

Widget NameDefault KeybindingDescription
fzf-file-widget^[^FFile search using fzf
fzf-history-widget^RHistory search using fzf
fzf-cd-widget^[cChange directory using fzf
fzf-git-log-widget^[^LGit log search using fzf
fzf-git-status-widget^[^SGit status search using fzf
fzf-variables-widget^VEnvironment variables search using fzf
fzf-package-widget^[^WFind a package name using fzf
fzf-git-blame-widget^[^BBlame search using fzf

Keybinding Notation

NotationMeaning
^Ctrl
^[Alt/Meta (Escape sequence)
^[^Alt/Meta followed by Ctrl (e.g., ^[^L means Alt+Ctrl+L)

Adding Custom Widgets

To add a new widget, create a file in the widgets/ directory following the naming convention fzf-<name>-widget.zsh. The plugin will automatically:

  1. Source the widget file
  2. Register it as a ZLE widget
  3. Bind it to a key (if configured in FZF_KEYBINDINGS)

Example widget file (widgets/fzf-custom-widget.zsh):

fzf-custom-widget() {
    local selected=$(your-command | fzf)
    if [[ -n "$selected" ]]; then
        LBUFFER="${LBUFFER}$selected"
    fi
    zle redisplay
}

Then add a keybinding before sourcing the plugin:

typeset -gA FZF_KEYBINDINGS
FZF_KEYBINDINGS[fzf-custom-widget]='^[^X'  # Alt+Ctrl+X