Tuan-Anh Tran

A better way to go through terminal command history

Posted on December 20, 2017  •  1 minutes  • 126 words

In the past, I used to use Ctrl+R to search my terminal command history but it’s unreliable. I couldn’t wrap my head around how it search sometimes.

Thanksfully, I was introduced to fzf and it’s has been a wonderful little gem. The power of fzf is much more than just searching through command history, depends on how creative you are.

The one I show here is just an example of how powerful fzf is. Basically, it can be pipe to just anything and fuzzy search that.

fh () {
    print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
}

Now go brew install fzf, add the above function and thanks me later 😁

Follow me

Here's where I hang out in social media