Fzf - File Search From Linux Terminal - GeeksforGeeks

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 :
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 https://github.com/junegunn/fzf.git
cloning fzf repo
Step 3: Navigate to the cloned folder.
cd fzf
Step 4: Run the installation script using the following command.
./install
installing fzf
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. 
In this example, we are opening a file called geeks.sh 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.
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
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.
ls
listing all files
Step 3: Run the uninstallation file i.e. uninstall, from this fzf directory to remove the fuzzy finder from your system.
./uninstall
Successfully uninstalled fzf
Linux-Tools
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
scp command in Linux with Examples
mv command in Linux with examples
chown command in Linux with Examples
Docker - COPY Instruction
nohup Command in Linux with Examples
SED command in Linux | Set 2
Named Pipe or FIFO with example C program
uniq Command in LINUX with examples
Thread functions in C/C++
Array Basics in Shell Scripting | Set 1