Ramblings of an aging IT geek
← Ramblings of an aging IT geek
tooling

the day fzf quietly took over my shell

How a single fuzzy finder rewired the way I navigate history, files and git branches in the terminal, with the bindings I actually use.

A keyboard lit up next to a terminal

I did not set out to change how I use the terminal. I installed fzf to do one thing, fuzzy-search my shell history, and a year later it has its fingers in almost everything: history, file selection, directory jumping, git branches, killing processes. The point of this post is the handful of bindings that earned their keep, not the tool itself, because the tool is just a fuzzy filter over stdin. The leverage is in what you pipe into it.

The default install gives you three things on a key. Ctrl-R replaces shell history search, and this alone justified it. Ctrl-T pastes a fuzzy-found path onto the command line. Alt-C cds into a fuzzy-found directory. That last one quietly retired a pile of aliases I'd built up over the years to jump around a deep project tree.

Then you start writing your own. The pattern is always the same: produce lines, pipe to fzf, do something with the selection. Here is the git branch switcher I use a dozen times a day:

fbr() {
  local branch
  branch=$(git branch --all | grep -v HEAD | sed 's/.* //' | fzf) || return
  git switch "$(echo "$branch" | sed 's#remotes/origin/##')"
}

It is four lines and it has completely replaced me typing branch names I half-remember. The same shape kills processes (ps into fzf into kill), checks out a file from a previous commit, or picks a kubernetes context. Once the muscle memory is "list, filter, act," you stop writing one-off scripts and start reaching for the filter.

A fuzzy finder mid-selection over a file tree

The single setting that made it feel native was the preview window. Pointing fzf at bat for files or git show for commits turns a flat list into something you can actually read before you commit to a choice:

export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --preview-window=right:60%"
export FZF_CTRL_T_OPTS="--preview 'bat --color=always --style=numbers {} 2>/dev/null || cat {}'"

The height matters more than it sounds. A full-screen fuzzy finder breaks the flow, you lose your scrollback and the context of what you were doing. Forty percent of the screen keeps your last command visible above it, so the finder feels like a drawer that slides up rather than a new application you've launched.

What surprised me is how much it changed my behaviour rather than just my speed. I used to keep a tidy, memorised set of paths and branch names because navigating was expensive. Now navigation is nearly free, so I let the project sprawl a bit, and I stopped caring whether a branch was called fix/auth or auth-fix because I'm never typing it, I'm filtering for "auth" and picking. The tool didn't just make an old workflow faster. It quietly removed the reason the old workflow existed.

If you only take one thing: install it, live with the three default bindings for a week, and then the first time you find yourself typing git branch and squinting, write the four-line function. That moment is when it stops being a history search and starts being how you use the terminal.