Skip to main content

TIL: fzf

I use Bash as my main shell and that’s probably not going to change in the forseeable future.1 It’s stable and widely used. And all people running their favorite shells still have Bash installed for uncompatible stuff. One of the ‘meh’ features of Bash is its built-in reverse search.

However, there’s a neat tool that I saw my colleague emdej use. Meet fzf, a command-line fuzzy finder.

Well, it’s much more than the tag-line says. The fuzziness can be used in many contexts and integrated anywhere you want (for example for matching hosts from the ssh config). fzf comes with default bindings for recursively searching files and commands from history. The latter, together with:

HISTSIZE=
HISTFILESIZE=
export HISTCONTROL=ignoredups:erasedups
shopt -s histappend
export PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND$'\n'}history -a; history -c; history -r"

for making the history infinite and reloading live2, makes my life much easier.


  1. Yep. I’m editing this post before publication in 2022 and it seems I was correct. Nothing’s changed in my setup in this matter. ↩︎

  2. I often use multiple terminal windows so sharing history (and saving it for later use!) is important for me. Default settings save the history to file on closing the session, with each session overwriting the history file with its own “fork”. ↩︎