I have been a Vim user for 12 years and one important thing that you learn the first days using it is that you can be super efficient typing commands to complete what you are trying to do.

I spend almost all my day coding in front of a console and at some point you realize that not only you can DRY your code, but your daily console commands also. From time to time, I really like to stop for a while and think about all the commands I have typed and see if I can execute them faster.

Few months ago, a friend of mine was trying to polish his daily pain points too and he created this awesome plugin for tmux called tmux-fingers but I decided to take another path. At the same time I discovered FZF and I thought it would be an interesting tool to play with.

This command-line fuzzy finder does one thing and does it well, just like the most ancient commands in UNIX. It takes an input and you can filter it to choose what you want in a interactive shell. So you can do things like this example:

I recommend to you to play with it a bit and start thinking about all the possibilities you can do with it. Review all the available FZF options and you will discover gems like multiselection (-m).

So, how do you shuffle FZF and Git to get this posts’ topic answered? Think about common git use cases that you do every day and you are going to think of things like this:

Switch between branches

Review some specific commit

Do interactive rebases

Edit changed files in a commit

We are going to get our hands dirty with one example:

git log --pretty=oneline | fzf

After executing the command below, you realize that you can search for a commit in you repository in an interactive way. If you press ENTER, the FZF’s output will be the selected line you chose. Now, try to execute this:

git show $(git log --pretty=oneline | fzf | cut -d=' ' -f1)

And you will get you first interactive git show. Hooray! :p