A general purpose command-line fuzzy finder.
It took a while for fzf to click for me. A lot of folks excitedly wrote about it and it certainly looked neat, but I was initially finding it hard to see the true productivity value it could bring to my CLI life. But, I decided to give it a try and I’m glad that I did.
Setup
Install is easy and there is a
brew
option as well. At time of writing, there is a second step to run an
install.
From there, you are off onto customization:
- Color schemes.
- Switch from
find
to fd. - Discover related projects.
- And down the rabbit hole.
Default usage
Out of the box, fzf
comes with a lot of neat functionality. My absolute
favorite feature is the history search. You hit CTR-r
and then you can fuzzy
find your entire CLI command history. This feature alone is enough for me to
keep fzf
forever! Countless times I have grabbed complex commands from my
history that I knew were there, if I could just find them. Now I can!
If you enabled the completion
feature, you
get some other nice goodies as well. For example, you can select a file by doing
vim **<TAB>
and then fuzzy select one or more files to edit. This one isn’t
always useful since some of my projects include a silly number of files. But, it
is certainly handy when it works out and saves you from having to TAB
down a
directory structure to finally find the file. There are several other
completions as well, the one for kill
is also very nice.
Going beyond
There are many projects that integrate with fzf
. Currently playing around with
forgit which wraps some git
commands with
fzf
. I especially like the file selector commands it has for adding, checking
out or resetting files.
The kubectx project also integrates with
fzf
. It is especially useful when you alias the commands to something shorter
like:
alias kc='kubectx'
alias kn='kubens'
I’m currently exploring if I can work fzf
into other parts of my kubectl
workflow, but haven’t nailed it down yet.
Conclusion
There is a lot to discover with fzf
and it is easy to get overwhelmed by the
configuration or the fancy commands that you can construct with it. I suggest just
installing it and using the default functionality first. If it is your cup of
tea, then go nuts on extending it. I do think the right way to build off of
fzf
is with shell functions or aliases so you can nail down the functionality
and make it really easy to invoke.