This article is more than 1 year old

I am broot: The Reg chats to French dev about Rust tool that aims to improve directory navigation

Why Rust? 'It works and usually does what you wanted it to do,' says dev

Interview Rust developer Denys Séguret, from Lyon, France, wanted a better way to view and search directories, so he coded his own, sparking interest from others with similar frustrations.

Broot is a command-line utility for listing and manipulating files and directories – basic functionality that you would have thought could hardly be improved, 50 years since the invention of Unix.

Séguret found that was not the case, particularly when it came to navigating source code that can have thousands of files in a single project. “I deal with many many projects, more than what my brain can memorise. So I always have to look a little to know how a project works,” he told The Register.

“I was doing this with ls, and regretting that tree doesn't really work when there are many files. So I had the idea to trim the tree so that I can get an overview. Most other ideas were quite natural from there.”

On Unix-like operating systems, the ls command lists files while tree provides a listing of all files including those in subfolders, which are often so numerous that what you want to see scrolls rapidly out of view.

By default, Broot does not list all files, but shows an overview, with notes like “50 unlisted.” Better still, if you type a few letters, it will show all matching files and directories, even if the letters are not consecutive. You can then easily select a directory and list all its files. You can also use regular expressions, a powerful means of pattern matching though arcane for the uninitiated.

Broot works on Linux, Mac and Windows 10, though the docs say that: “While the Linux version is quite well tested, the other versions are lacking testers and involved developers.”

That is a shame, since Broot can do something the Windows File Explorer cannot, which is to show how much space is occupied by a directory including all its sub-directories. This is of great value when drives fill up, not uncommon with SSDs typically being less capacious than spinning metal. On Windows there is always TreeSize Free, but a command-line alternative is welcome.

While we successfully ran Broot on Windows, it is slower than on Linux and some features did not work. That said, it was still many times faster than Search in Windows File Explorer for finding a file in a deeply nested folder.

The utility has some other nice features, including an option to respect gitignore files, which determine which files are covered by git source control. There are options to show hidden files, file permissions and file date and time. You can also define shortcuts for commands you use often, including one or more arguments. Commands for moving files and creating or removing directories are built-in. You can execute applications or editors. You can also customise the colouring by using a configuration file.

Broot is coded in Rust, of which Séguret remarks, “There's this thing quite new in Rust: when you make your code compile, it works and usually does what you wanted it to do.” Ho ho.

Why the name? “At the beginning it was b-root,” said Séguret, “which is a reference to b-tree, balancing tree, as the basic idea is to dive into all branches in parallel, and also taking into account that what we call trees look more like root systems (i.e. going towards the bottom). And broot sounds like "broute", which means graze in French, hence the cow as a logo.”

The utility has been the subject of generally favourable discussion on HackerNews. One commenter said, “I don’t care if its been done before … broot just WORKS! and it works well, I finally got rid of all the aliases around ls that I used in order to get info I want.” Another said, “This has replaced nnn for me and solves so many devops headaches.” The nnn utility is another lightweight file manager.

Broot is currently at version 0.11.3; the code is on GitHub. How close is version 1.0? “I was expecting to do it about next week. But due to the HackerNews exposure (the tool was discussed this morning on techie message board institution HackerNews), I've received today a lot of issues and suggestions, and some fixes (for mac or zsh) seem to be necessary.”

That said, “it looks like there's nothing big preventing the 1.0,” Séguret told us. After that, he has "a few ideas for broot, some of them quite big," he said, but would not be drawn on specifics.

What about Windows? “I'm not sure for Windows. I'm not even sure it really fits the culture. I mean: if people don't use the console at all, there's no point in such an application,” said Séguret. He may be surprised by the level of interest, with terminal usage growing on Microsoft’s platform. ®

More about

TIP US OFF

Send us news


Other stories you might like