fzf
is a command line fuzzy finder that can be used to automatically filter a list of items. Think of it as an interactive search tool, where items get filtered as you type characters in your terminal.
The video below shows a basic interaction using a list or files from the fd
search utility:
fzf
can also be used with other Bash tasks, like history, ssh and even file/dir completion. The GitHub page has a lot documentation on how to implement auto completion.
You can also use the --preview
option to output the current selection into a preview box, and even call a command to be used with that value. For example, we can preview all the files in a folder by searching for files (with find
or fd
), piping the output to fzf
, and then using a program like cat
(on the example below I’m using bat
, which is a clone of cat
with the addition of syntax highlight and other cool things) to preview the files.
fd -d 1 -t f | fzf --preview 'bat --color "always" {}' --preview-window=right:60%
I’ve covered only the very basic usage for fzf
, but it should give you an idea of how powerful this finder utility is. On future posts I’m going to cover other use cases, like the git workflow that I use.
References: