Get along with fzf for Terminal

kojikanao profile image Koji (he/him) ・2 min read

This is for my next Git post.
I started playing with .gitconfig and got known a great tool, fzf.
fzf can make things easy!!!

fzf is a general-purpose command-line fuzzy finder.

In this post, I will show what we can do, how to install and a couple of usages.

What We Can Do with fzf

In the following gif, I tried history first then I used h | fzf (h is an alias of history). As you can see, you can find out the command you want to see easily with fzf.
fzf allows us to use git checkout interactively like below.
In addition, you can customize commands with fzf and many people write scripts. In the bottom of this post, I put the link which is very useful for people who want to try fzf. You can also set shortcut keys.




This post supports MacOS and Ubuntu since I have used both of them.

# MacOS
$ brew install fzf

# Ubuntu
$ sudo apt-get install fzf

If you are using Windows, I highly recommend you to start using chocolatey(https://chocolatey.org/) which is a package manager software.

Simple Usage

File search

I did this command in my Gatsby site folder and searched my components.

$ fzf
$ fzf --reverse


History search

This is very useful to me since I usualy do h | grep 'something' for checking commands I typed before.

$ history | fzf
$ history | fzf --reverse


If you add --reverse you can change the layout like this(maybe better)

Open file with fzf

$ open $(fzf)


Update package with fzf

Sometimes I do typo then get an install error lol

$ brew upgrade $(brew outdated | fzf)
# Then choose a package. Probably user --multi.


jq with API

This is not helpful, but if we need to check a big json return from API with curl command, this might be good ???
By the way, for jq you need to instal jq.

$ curl https://samples.openweathermap.org/data/2.5/weather\?lat\=35\&lon\=139\&appid\=b6907d289e10d714a6e88b30761fae22 | jq | fzf --reverse


More Information


You can see more information here (https://github.com/junegunn/fzf/wiki/examples).

Key bindings for command-line

Suggestion from @vonheikemen

Posted on by:

kojikanao profile

Koji (he/him)


Looking for opportunities! Software Engineer in NYC/Research Resident@NYU-ITP18-19 Mostly I work with reactjs and sometimes python. code to do something weird/useless/helpful Japanese


markdown guide

It is worth mention that fzf comes with a few handy functions to search the command history and also directories. You just need find and source the fzf/key-bindings.bash file (there is also one for zsh and fish). More info about it here.