Broot content search

3 minute read Published: 2020-07-26

An example of an efficient search workflow based on broot, a general purpose file manager.

Here's how broot looks when launched on my big code directory with br -s ~/dev (300k files, 22GB):


I want to look for examples of Option<Option (an option of an option in Rust).

The command for such filtering is c/Option<Option (c/ then the searched string).

Broot lists the matching files in real time, in a tree view helping you get a clear overview, and with a relevant extract in green.


In practice you rarely bother typing the whole searched string, you type just as much as is needed to discriminate what you're looking for.

If I want to know more about a given file, I hit ctrl (after that, I can close it with ctrl) :


Broot now shows me the matching lines in the chosen file.

It's now clear this match is just the blog post I'm typing... not very interesting.

So I hit the tab key to navigate to other matched files. The preview is automatically updated:


The tree lets me see those options of options occur in BurntSushi's regex crate and it's quite obvious (when you've done some Rust) that iterations are the reason of such type.

Another ctrl lets me focus the preview panel and then I navigate among matched lines using and :


Hitting ctrl again dives in the file on the selected line so that I can see the context.


(it confirms the Iterator hypothesis)

I can go back to the list of matched lines with ctrl.

And if I want to open the file in the editor, I type :e (or a space and a e):


and I hit enter to go to my favorite text editor on the relevant line:


When I quit vim, I'm back to broot.

How fast was it ?

Quite fast. In fact with my SSD there's practically no delay in such a workflow. In my tests on big directories full of git repositories, broot is much faster than grep, ripgrep, ag, etc.

(but broot doesn't really have the same features, it doesn't let you run a regular expression or even a case insensitive search on the file contents of a directory, it just does the easy search of literals)

(and that was on my machine and in no way a serious benchmark, so let's just remember it's "fast enough")

Other searches

broot's query syntax allows filtering on file names with a fuzzy pattern or a regular expression, and to compose the conditions.

For example, when noticing the md file in my result list, instead of going to the next result, I could have completed the query to exclude files whose name ends in md:


(see more here)