Home

Awesome

fzf-zsh-plugin

License Awesomebot MegaLinter Code Climate

<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

Table of Contents

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

This ZSH plugin enables using fzf to search your command history and do file searches.

It will automagically install fzf into your home directory if it isn't already there, and bind ^R to an fzf-powered search of your command history.

Created for the zsh-quickstart-kit to make the default setup have a more 'batteries included' feel.

Yes, there is a plugin baked into oh-my-zsh, this allows easy fzf integration for other frameworks and shells, and adds some helper scripts.

Note - while these scripts could all be ZSH functions instead of scripts in the bin directory, it uses standalone scripts so that non-ZSH users can also use the repository by adding its bin directory to their $PATH.

Contents

NameDescriptionAuthor
asdf-installInstall one or more versions of the specified language with fzf and installs your selection with asdffzf wiki
asdf-uninstallSelect one or more versions of the specified language with fzf and uninstalls your selection with asdffzf wiki
chrome-bookmark-browserRummages through your Chrome bookmarks with fzf and opens the selected bookmark(s) in your default browserfzf wiki
d-attachUses fzf to select docker containers to start and attach to.From the fzf wiki
d-image-rmUses fzf to select docker images to remove.From the fzf wiki
d-rmUses fzf to select docker containers to remove.From the fzf wiki
d-stop-containerStop a Docker container.?
faliasSearches your ZSH aliases, then puts your selection on the mac clipboard (macOS only)?
fifUses fzf and rg to find a term in filesBoost Your Command-Line Productivity With Fuzzy Finder
fzf-brew-cask-installUses fzf to select programs to install (or show the home page) based on the output of brew cask searchBoost Your Command-Line Productivity With Fuzzy Finder
fzf-brew-cask-uninstallUses fzf to select brew-installed programs to delete (or show the home page)Boost Your Command-Line Productivity With Fuzzy Finder
fzf-brew-installUses fzf to select programs to install based on the output of brew searchBoost Your Command-Line Productivity With Fuzzy Finder
fzf-brew-uninstallUses fzf to select brew-installed programs to deleteBoost Your Command-Line Productivity With Fuzzy Finder
fzf-brew-updateUses fzf to select brew-installed programs to updateBoost Your Command-Line Productivity With Fuzzy Finder
fzf-browse-podsUse fzf to select a k8s pod. Preview shows pod's log tail output.Using fzf as the secondary filter
fzf-find-editUses fzf to select files (displaying previews) to edit with $EDITORBoost Your Command-Line Productivity With Fuzzy Finder
fzf-git-branchUses fzf to select a branch name in a git repository for use in scriptsFrom Mark Nielsen's Fuzzy Git Checkout article
fzf-git-checkoutUses fzf to check out a branch in a git repositoryFrom Mark Nielsen's Fuzzy Git Checkout article
fzf-grep-editUses fzf to select files (displaying previews) that contain a search term to edit with $EDITORBoost Your Command-Line Productivity With Fuzzy Finder
fzf-killUses fzf to select processes to killBoost Your Command-Line Productivity With Fuzzy Finder
fzf-vscodeUses fzf and rg to search for text and then open the file in vscodeHangops post by Mark Carey
lessfilter-fzfA less pre-processor to nicely display a wide range of file formats, including images and directories that can be used to show fzf previews (see Customization section).Aloxaf/fzf-tab - Wiki/Preview
pr-listUse fzf to select a PR using gh?
tmUses fzf to search for a tmux session or create one if there are no matches.From the fzf wiki
tmux-killUses fzf to select a tmux session and kill it.From the fzf wiki
tmux-searchUses fzf to select a tmux session. Skips fzf if there's only one match, exits if no match.From the fzf wiki
vagrant-box-searchUses fzf to select a vagrant box and connect to it with ssh.From the fzf wiki

Installing

You should set this plugin to be last, or near to last in your framework's list of plugins to load. It dynamically generates $FZF_DEFAULT_OPT and $FZF_DEFAULT_COMMAND based on whether it sees things like rg and bat in your $PATH, so it should come after other plugins have had a chance to extend your $PATH.

Zgenom

Add zgenom load unixorn/fzf-zsh-plugin to your .zshrc with your other load commands.

Antigen

Add antigen bundle unixorn/fzf-zsh-plugin@main to your .zshrc

ā˜ Note that until https://github.com/zsh-users/antigen/issues/717 gets fixed in Antigen, it only recognizes plugins in master branch. So you need to explicitly specify @main here.

Oh-My-Zsh

  1. git clone --depth 1 https://github.com/unixorn/fzf-zsh-plugin.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/fzf-zsh-plugin
  2. Add fzf-zsh-plugin to your plugin list - edit ~.zshrc and change plugins=(...) to plugins=(... fzf-zsh-plugin)

Without using a framework

  1. git clone --depth 1 git@github.com:unixorn/fzf-zsh-plugin.git, then add its bin directory to your $PATH.
  2. Add source /path/to/repository/checkout/fzf-zsh-plugin.plugin.zsh to your .zshrc file.

The scripts in this collection don't actually require you to be using ZSH as your login shell, they're being distributed as an oh-my-zsh-compatible plugin because it's convenient for me.

(optional) Install recommended tools

Optionally, to make the most out of fzf preview (? toggle), install the following tools and enable the advanced preview (see Customization section):

Customization

You can customize a few features by exporting the following environment variables in your init script (.zshrc/.bashrc or similar):

Export variableDescription
FZF_PREVIEW_ADVANCEDUse less viewer with a pre-processor to display improved previews for a wide range of files (requires you to install at least eza, bat, chafa, exiftool; and very recommended lesspipe.sh and the tools it uses underneath: mdcat, in2csv,...). This is an opt-in feature.
FZF_PREVIEW_WINDOWSet any value supported by fzf --preview-window option, e.g. right:65%:nohidden will show the preview by default.
FZF_PATHPath to install fzf binary and script, e.g. ${HOME}/.config/fzf.
FZF_COLOR_SCHEMEColor scheme for fzf, e.g. --color='hl:148,hl+:154,pointer:032,marker:010,bg+:237,gutter:008'

A note on lessfilter-fzf

You can also use it as a general less preprocessor to extend the less capabilities. To do that, place the following in your shell init scripts (.zshrc/.bashrc or equivalent):

export LESSOPEN='| lessfilter-fzf %s'

Ultimately, lesspipe.sh (if present) will still honor your own lessfilter if found in your PATH, leading to the following execution: lessfilter-fzf > lesspipe.sh > lessfilter.

Other FZF resources