Augment your fish command line with fzf key bindings.
[![latest release badge]][releases] [![build status badge]][actions] [![awesome badge]][awesome fish]
fzf.fishto interactively find and insert into the command line:
./to the selection if only one selection is made and it becomes the only token on the command line, making it easy to execute if an executable, or cd into if a directory (see cd docs)
functions/), then search will be scoped to that directory
Altto prevent overriding
Altto prevent overriding clear screen)
$historyis excluded for technical reasons so use the search command history feature instead to inspect it
The prompt used in the screencasts was created using IlanCosman/tide.
First, make sure you're using Fish
$ fish --version fish, version 3.1.2
Next, install with Fisher.
fzf.fishcan be installed manually or with other plugin managers but only Fisher is officially supported.
fisher install PatrickF1/fzf.fish
Finally, install the following CLI tools:
catwith syntax highlighting (used to preview files)
For macOS, I recommend installing them using brew.
On certain distribution of Linux, you will need to alias
If you would like to customize the key bindings, first, prevent the default key bindings from executing by setting
fzf_fish_custom_keybindingsas an universal variable. You can do this with
set --universal fzf_fish_custom_keybindings
Do not try to set
config.fishbecause the key binding configuration is sourced first on shell startup and so will not see it.
Next, set your own key bindings by following conf.d/fzf.fish as an example.
fzf supports setting default options via the FZFDEFAULTOPTS environment variable. If it is set, fzf will implicitly prepend its value to the options passed in on every execution, scripted or interactive.
To make fzf's interface friendlier,
fzf.fishtakes the liberty of setting a sane
FZF_DEFAULT_OPTSif it is not already set. See conf.d/fzf.fish for more details. This affects fzf even outside of this plugin. If you would like to remove this side effect or just want to customize fzf's default options, then set your own
FZF_DEFAULT_OPTSuniversal variable. For example:
set --universal --export FZF_DEFAULT_OPTS --height 50% --margin 1
Alternatively, you can override it in your
set --export FZF_DEFAULT_OPTS --height 50% --margin 1
The search files feature, by default, uses
lsto preview the contents of a directory. To integrate with the variety of
lsreplacements available, the command used to preview directories is configurable through the
fzf_preview_dir_cmdvariable. For example, in your
config.fish, you may put:
set fzf_preview_dir_cmd exa --all --color=always
Do not specify a target path in the command, as
fzf.fishwill prepend the directory to preview to the command itself.
To pass custom options to
fdwhen it is executed to populate the list of files for the search files feature, set the
fzf_fd_optsvariable. For example, to include hidden files but not
.git, put this in your
set fzf_fd_opts --hidden --exclude=.git
See the FAQ Wiki page.
fzf.fishis a useful plugin, it is by standing on the shoulder of giants. There are two other fzf integrations for Fish worth regarding: jethrokuan/fzf and fzf's out-of-the-box Fish extension. The Prior Art Wiki page explains how
fzf.fishcompares to and improves on them.
Need help? These Wiki pages can guide you: