Searching the bins

This blog entry was ported from my gemsite, so it follows a slightly different format than I've been using here. The date on it is also wrong, but it's the date under which it was listed on my gemlog and I can't find an older one recorded anywhere.

I keep a lot of my things tagged with identifiers and stashed away in bins. To keep track of which bins hold which things, I keep a set of TSV files matching identifiers to bins, item descriptions, and other category-specific fields.

Until today, whenever I needed to locate an item I'd pull up a terminal, navigate to my inventory directory, and run "grep -ri 'some item'". It worked well enough, but I've been wanting to explore what could be done to streamline my workflow using tools like fuzzel and fzf for a while now. Searching my inventory interactively seemed like a natural fit for fzf.

fzf is a "command-line fuzzy finder." It takes some input from stdin, provides an interactive text-based interface for searching through it, and outputs the user's final selection to stdout. It also has a "preview" flag, which takes a command string to be executed on the user's current selection and presents the output in a preview pane alongside the search interface.

I was able to combine this flag with a script that pretty-prints an inventory entry to create a simple command-line interface for exploring my inventory entries. I bound this to a hotkey in sway, and now I can look up anything in my inventory with just a few keystrokes! 😁

I describe the system in greater detail, and provide the source code for these scripts, on my "bins" system page.