Fzf – A Quick Fuzzy File Search from Linux Terminal
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.
The following GIF shows how it works.
To install Fzf, you need to git clone the fzf’s Github repository to any directory and run 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 as shown in the following screenshot.
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 >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 **<Tab> $ unalias **<Tab> $ export **<Tab>
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.
fzf is being actively developed and can be easily upgraded to latest version using following command.
$ cd ~/.fzf && git pull && ./install
To see the complete list of usage options, run man fzf or check out its Github Repository: https://github.com/junegunn/fzf.
Fzf is a blazing fast and general-purpose fuzzy finder for quickly searching files in Linux. It has many use cases, for example, you can configure custom usage for your shell. If you have any questions or comments, reach us via the feedback form below.