fzf is cool
I've been playing around with fzf the past couple days to see if I can replicate some of my Alfred workflows in the terminal, and I have a conclusion: fzf is cool.
fzf is a command-line tool that lets you "fuzzy find" items from a list, progressively filtering the list as you type and selecting the best match from the remaining results. It can handle a pretty big input list (my current one has ~92,000 items) with near-zero lag.
Cooler yet: you can give fzf a preview command that runs whenever you select an item. fzf will display the output of that command in a preview pane, giving you a detailed view of each item as you search.
But I'm most excited about what I just learned this week: you can bind hotkeys to run arbitrary commands against the selected item. So cool. Here's an example of what you can do by stringing all of this together:
- Display a list of all your customers for fuzzy searching.
- For the selected customer, in the fzf preview pane, display their full legal name, website URL, geographic region, primary contact info, account team details, and anything else you can think of.
- Bind the following hotkeys:
F1
copies the customer name to the clipboard.F2
opens the customer in your CRM.F3
opens the customer in your [arbitrary internal dashboard / tool].- Etc.
Here's what the invocation might look like:
uv run account_list.py | fzf \
# Feed the selection back into my script to get the preview
--preview="uv run account_list.py --fzf-preview {}" \
# Use the fzf header as help text for the bound commands:
--header="[F1: Copy name | F2: CRM | F3: Custom dashboard]" \
# Bind the commands:
--bind='f1:execute(echo -n {} | pbcopy)' \
--bind='f2:execute(uv run account_list.py --open-crm {})' \
--bind='f3:execute(uv run account_list.py --open-dash {})'
This is awesome. Now I can make little mini applications on top of fzf that actually work better in some ways than what I've built in Alfred.
Why am I bothering? Well, my work laptop is due for a refresh, and I recently learned that when I request a new one, I might be forced to move from a Macbook to a Chromebook. That would mean no more Alfred or any other macOS-only app. At first I considered this a non-starter and was building a wall of "business justification" for why I should be allowed to get another Macbook. But that's given way to fixation on whether I could replicate my key tooling in Linux (Chromebooks do Linux!) and maybe be just as happy.
To be continued...