Fzf is a tiny, blazing fast, general-purpose, and cross-platform command-line fuzzy finder, that helps you to search and open files quickly in Linux and Windows operating system. It is portable with no dependencies and has a flexible layout with support for Vim/Neovim plugin, key bindings, and fuzzy auto-completion.
To install Fzf, you need to git clone the fzf’s Github repository to any directory and run the install script as shown on your Linux distribution.
$ git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf $ cd ~/.fzf/ $ ./install
After running the script, you will be prompted to enable fuzzy auto-completion, key bindings and update your shell configuration file. Answer y (for yes) to the questions.
On Fedora 26 and above, and Arch Linux, you can install it via a package manager as shown.
$ sudo dnf install fzf #Fedora 26+ $ sudo pacman -S fzf #Arch Linux
Now that you have installed fzf, you can start using it. When you run fzf, it will open an interactive finder; reads the list of files from stdin, and writes the selected item to stdout.
Simply type the name of the file you are looking for in the prompt. When you find it, click enter and the relative path of the file will be printed to stdout.
$ fzf
Alternatively, you can save the relative path of the file your are searching, to a named file and view the content of the file using a utility such as cat command or bcat.
$ fzf >file $ cat file OR $ bat file
You can also use it in conjunction with the find command, for example.
$ find ./bin/ -type f | fzf >file $ cat file
How to Use Fuzzy Completion in Bash and Zsh
To trigger fuzzy completion for files and directories, add the ** characters as a trigger sequence.
$ cat **<Tab>
You can use this feature while working with environmental variables on the command-line.
$ unset ** $ unalias ** $ export **
The same applies to the ssh and telnet commands, for auto-completing host names that are read from the /etc/hosts and ~/.ssh/config.
$ ssh **<Tab>
It also works with the kill command, but without the trigger sequence as shown.
$ kill -9 <Tab>
How to Enable fzf as Vim plugin
To enable fzf as a vim plugin, append the following line in your Vim configuration file.
set rtp+=~/.fzf
fzf is being actively developed and can be easily upgraded to latest version using following command.
$ cd ~/.fzf && git pull && ./install