DEV Community

Benjamin Kadel
Benjamin Kadel

Posted on

Must have tool for a Terminal User - FZF "Terminal Fuzzy Finder" [Video Included]

fzf is amazing, let me tell you and show you (video at end) why!

fzf is a Terminal Fuzzy Finder, that essentially means that you can pass fzf a list of anything and fzf will turn that list into a search bar with a up & down arrow key menu for you, as you type your search fzf will try and guess what you wanted to find and start delivering suggestions based on what you have typed in so far...

fzf can be installed with your package manager:

brew install fzf
apt-get install fzf
pacman -S fzf

and can be used immediately as a file finder in your current working directory by typing and executing:


this alone will show you a searchable list of all files in the current directory that you are in and in sub-directories recursively all the way down (if that makes sense).
Once you picked your file that you want, either by narrowing down the list with typing the name or parts of the name or by simply using the arrow keys up and down and enter to select, then fzf will simply echo to standard out (stdout) the file name which you chose...
Pretty rubbish right?
"why the heck would I want just the name of the thing I just picked printed right back out to me??"
I hear you scream? ...


Why dont you pipe that output (the file) you chose into another command, like rm (then you have made an interactive file deleter) or cat (then you have made an interactive file reader) or any other command?!? The possibilities are endless (well sort of). fzf is a tool that really becomes incredibly powerful when you combine it with other tools!

In the above examples we would do...

fzf | xargs -I '{}' rm {}
fzf | xargs -I '{}' cat {}

I wont go into the use of 'xargs' in these commands now, but the short version is that xargs converts the result of the previous command, that is being piped into our new command (rm / cat), into the proper format for that command, we are still passing the string of the filename just in a way that those commands can deal with it. Xargs is not necessary for all commands, for more information please check out this stack-exchange question on the issue...

Anyway there you go by combining fzf (the picker) with another command you can create really powerful interactive tools to use in your workflow...


As I said, using simply the fzf command on its own gives you files, however fzf can accept things being piped into it and the real power actually comes from passing things into fzf for it to present back interactively to you...

You can pass fzf a list of things, over multiple lines as input and fzf will use its magic to break down, line by line, that list and give you a "menu/searchable" version of it. To do that simply echo multiple lines and pipe the output into fzf...

so, this code:

echo -e "One\nTwo\nThree" | fzf

this would pass fzf a list of:
(the \n is the newline character, basically printing out a newline).
And fzf will take it and turn it into one of its awesome searchable menus that you can then interact with and get into stdout the chosen choice, which OFCOURSE you can then pipe further on into some other command!

So hopefully I am painting the picture that fzf alone sure is cool, but the real awesome power comes from sticking fzf in-between, a list of things that you pass it whatever that may be and some other command that uses your selection.

Its essentially an amazing interactive converter of many-to-one that you can and should use in scripts and tools all across your system!

Here is the official page with all the information about fzf I would recommend checking it out to learn more...
Github page for fzf

Finally, a video

Below is a video that I have created on this very topic that I would like to share with you. In the video I do a much better job of showing off and explaining fzf with a real demo in the Terminal!

In the video I even create an example of where fzf might be really useful in a real world scenario, in your git workflow, I create in one simple line (that can be turned into an alias) a collection of commands that make an interactive git branch picker, so you never need to type git branch blahblah again, instead you simply pick it from a searchable "fzf" list...

Here is the gist of the Interactive Git Branch Changer that you can learn about in the video below:

You see the power now?

Thanks for reading (and maybe watching) folks. So I am trying to grow my new YouTube channel too (as you can probably tell by the video)...


So please give me as much feedback & criticism as possible so that I can improve and if you liked it or any other video that I have done please share it around, it would really help!

For any questions about anything you have seen here or in any of my other videos or even if you have ideas for future videos, please reach out on twitter


Top comments (0)