Here’s a quick blog post covering a neat Linux package called fzf. It’s easy to install, either from GitHub or via your package manager. For Debian- or Ubuntu-based distributions, it’s apt-get install fzf.

The way that fzf works is that it provides you an interactive search capability on your command line. Suppose for example that I’m looking for a file somewhere in my home directory. When you start up fzf it scans the list of files (recursively) and then provides you a prompt.

Searching for a file.

Then, as you type in text, it’ll search for matching files. For example, suppose I want to search through MegaMek and find things related to the Capellan Confedration so that I can delete everything associated with those bums. Start typing and you get info on how many files there are, so 26,441 of 191,988 files in my /home/{username} directory need purged (and given who the Capellans are, I’m sure they wouldn’t appreciate the irony of getting purged).

I’m not saying House Marik is the best, but that’s because I don’t need to say it.

Hit enter on a file and it’ll paste the relative location of the file to your console.

Getting file names.

Running fzf -m, you can enter multi-select mode, allowing you to select multiple files using the Tab key. There’s also some fancy regular expression-like search options, so I could look for png files which include “atlas” in the name and are in a “mechs” folder.

Protip: the Atlas mech is the best scout mech. Very stealthy and scouty. Just watch out for the bees.

You can also pipe things into fzf. For example, here’s history | fzf and I’m looking for build commands, such as maybe the last time I did a docker run so I can re-run a prior command.

So many Docker commands.

When running fzf --preview 'cat {}', it will use the cat command to show a preview in a segment of the terminal.

You thought you could hide, test_data.txt? Not for long!

There’s a lot more you can do with the program, but even this is a great start. And by the way, there’s a version for Windows too. And MacOS if you’re into that sort of thing.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s