Skip to content
Related Articles

Related Articles

Improve Article
Fzf – File Search From Linux Terminal
  • Last Updated : 11 May, 2021

Fzf is a command-line general-purpose fuzzy finder tool. It is somewhat like grep. It is a cross-platform command-line tool, that helps you to search and open files quickly. Furthermore, it is open-sourced portable with no dependencies. It has supports for Vim/Neo vim plugin, key bindings, and fuzzy auto-completion. It can be used with any list; files, command history, processes, hostnames, bookmarks, git commits, etc.

Installation on the various platform through package manager :

 Package ManagerLinux DistributionCommand
1.APKAlpine Linuxsudo apk add fzf
2.APTDebian 9+/Ubuntu 19.10+sudo apt-get install fzf
3.Conda conda install -c conda-forge fzf
4.DNFFedorasudo dnf install fzf
5.NixNixOS, etc.nix-env -iA nixpkgs.fzf
6.PacmanArch Linuxsudo pacman -S fzf
7.pkgFreeBSDpkg install fzf
8.pkg_addOpenBSDpkg_add fzf
9.XBPSVoid Linuxsudo xbps-install -S fzf
10.ZypperopenSUSEsudo zypper install fzf

Installation using Git:

Step 1: Open up the terminal and run the following command to see if git is installed on your machine or not.

git --version

If the output looks like this, then you are good to go, or else you need to install git first on your system. You can install git by running the following command:

 sudo apt install git-all

Step 2: Clone the fzf repository using the following command:

git clone --depth 1
Fzf a Quick Fuzzy File Search from Linux Terminal

cloning fzf repo

Step 3: Navigate to the cloned folder.

cd fzf

Step 4: Run the installation script using the following command.

Fzf a Quick Fuzzy File Search from Linux Terminal

installing fzf


Using fzf to search and open a file:

nano is a text editor, and we are going to open the searched file in nano. And (fzf –height 40%) will open a fuzzy finder window within 40% of the screen.

nano  $(fzf --height 40% ) 

Note: we can replace nano with other utility commands like cat(used to view a file), rm(used to remove a file), kill(used to kill a running process), cd( to change directory),etc. 

Fzf a Quick Fuzzy File Search from Linux Terminal

In this example, we are opening a file called using a fuzzy finder prompt. We can use the keys to navigate through, or we can just type the name of the file that we are looking for. 

We can use the keyboard key to navigate through the list of items/files.

  • CTRL-J / CTRL-N to the move cursor down and  CTRL-K/ CTRL-P to move the cursor up.
  • Use any of these CTRL-C / CTRL-G / ESC  key combinations to exit from the finder.
  • To select multiple files run fzf  as fzf -m i.e. multi-select mode (-m), and use TAB to mark multiple items/files.
  • Use  Mouse: scroll to scroll through items/files, right-click to multi-select the file, left-click/double-click to open the file.

Using multi-select mode:

To select multiple files in finder, we open fzf in multi-select mode using -m argument. The red triangle in front of the items/files shows that these files are selected. After selecting desired files hit ENTER to display their path location.

fzf -m
Fzf a Quick Fuzzy File Search from Linux Terminal

selecting multiple files

Steps to Uninstall fzf:

Step 1: Navigate to fzf directory using following command:

cd fzf

Step 2: Use ls command to list all the items in that directory.

Fzf a Quick Fuzzy File Search from Linux Terminal

listing all files

Step 3: Run the uninstallation file i.e. uninstall, from this fzf directory to remove the fuzzy finder from your system.

Fzf a Quick Fuzzy File Search from Linux Terminal

Successfully uninstalled fzf

My Personal Notes arrow_drop_up
Recommended Articles
Page :