Usage

To launch the interactive UI, run:

fzf

When no arguments are supplied, fzf launches an interactive finder with file suggestions provided by find .

You can then enter search terms separated by SPACE , navigate with Arrow-UP and Arrow-DOWN , select multiple files with TAB , and confirm by pressing ENTER . When done, the paths of the selected files will be printed on the screen.

In the example below, I run fzf , search for READ, select the files with TAB , and confirm with ENTER :

fzf example

For single selection, TAB is not necessary. Just press ENTER when the desired entry is highlighted.

We can also use the output of fzf as an argument for another command:

vim $(fzf)

Because fzf can read a list from STDIN, process it, and write the selected items to STDOUT, things become more interesting when fzf is run in conjunction with other commands.

# npm search

npm search react | fzf # grep

grep -irl react * | fzf # PATH folders

echo $PATH | tr ':' '

' | fzf

If you use zsh , you can add a global alias for | fzf :

alias -g Z='| fzf' # change Z to whatever you like

The same examples can then be written as:

npm search react Z

grep -irl react * Z

echo $PATH | tr ':' '

' Z

Key bindings

The install script adds, by default, three key bindings:

CTRL-T

Paste the selected files and directories onto the command line.

In the example below, I start by typing vim then CTRL-T , the fzf UI shows up letting me search for the file I wanted. Once I find the file, I press ENTER to return to my vim command with the file path.

CTRL-T example

You can select multiple files and directories with TAB and Shift-TAB , the paths will be all pasted onto the command line separated by a space. It’s very useful when you want to rm or cat multiple files.

2. CTRL-R

Paste the selected command from history onto the command line.

In the example below, I simply invoke the UI by pressing CTRL-R , and then I can search for any command previously executed, in this case, I was looking for the npm command to list all my globally installed packages without their dependencies.

CTRL-R example

3. ALT-C

Cd into the selected directory.

In the example below, I can quickly cd (without typing cd ) to the src folder of my personal-website repo from my workspace folder.

ALT-C example

If your terminal processes ALT-C as ç, you can add the following line to your .(ba|z)shrc file after the source commands:

bindkey "ç" fzf-cd-widget

Fuzzy completion alias

By default, the install script defines the fuzzy completion trigger as ** .

If you, like me, use zsh , you probably use ** a lot as part of its filename generation (a.k.a. Glob) and that can be confusing, but worry not, we can easily customize it by setting FZF_COMPLETION_TRIGGER in your .zshrc file:

export FZF_COMPLETION_TRIGGER='**' # change ** to whatever you like

The fuzzy completion is aware of the command that precedes it, meaning the suggestions can change based on what you are trying to do:

# Directories under current directory (single-selection)

cd **<TAB> # Files under your home directory (multi-selection)

vim ~/**<TAB> # Host names are extracted from /etc/hosts and ~/.ssh/config

ssh **<TAB> # Environment variables

unset **<TAB>

export **<TAB> # Aliases

unalias **<TAB>

Also, fuzzy completion for PIDs is provided for kill command. In this case, there is no trigger sequence, just press the tab key after the kill command.

# Can select multiple processes with <TAB> or <Shift-TAB> keys

kill -9 <TAB>

There are some experimental APIs for customizing fuzzy completion and enabling it for other commands.

Search syntax

Besides the already discussed fuzzy search, fzf supports special tokens that change the way search terms are processed:

'wild : Exact match, return items that include wild .

: Exact match, return items that include . ^music : Prefix-exact-match, return items that start with music .

: Prefix-exact-match, return items that start with . .mp3$ : Suffix-exact-match, return items that end with .mp3 .

: Suffix-exact-match, return items that end with . !fire : Inverse-exact-match, return items that do not include fire .

: Inverse-exact-match, return items that do not include . !^music : Inverse-prefix-exact-match, return items that do not start with music .

: Inverse-prefix-exact-match, return items that do not start with . !.mp3$ : Inverse-suffix-exact-match, return items that do not end with .mp3 .

Note that SPACE acts as an AND operator and | as an OR . For example, a query that matches entries that start with music and end with either mp3 , wav , or flac would look like this: