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.

Fzf - File Finder for Linux

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.

Install Fzf in Linux
Install Fzf in Linux

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
Fzf Prompt
Fzf Prompt

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
$ 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>
Auto Completion of Filenames
Auto Completion of Filenames

You can use this feature while working with environmental variables on the command-line.

$ unset **<Tab>
$ unalias **<Tab>
$ export **<Tab>
Auto Completing Env Variable in Linux
Auto Completing Env Variable in Linux

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>
Auto Completing Hostnames
Auto Completing Hostnames

It also works with the kill command, but without the trigger sequence as shown.

$ kill -9 <Tab>
Auto Completion for Kill Command
Auto Completion for Kill Command

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

To see the complete list of usage options, run man fzf or check out its Github Repository: https://github.com/junegunn/fzf.

Read Also: The Silver Searcher – A Code Searching Tool for Programmers

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.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Got something to say? Join the discussion.

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.