Mastodon hachyterm.io

It’s become popular to rewrite classic command-line tools in Rust:

Shell is the essential tool for every programmer. The more familiar you become with the available tools, the more efficient you can be with using your computer.

Many Rust alternatives provide a modern, faster, and more user-friendly alternative.

One of them is broot.

What Is broot?

broot is a combination of ls (for listing directory contents) and tree (for listing contents in a tree-like format). You can use broot to get an overview over a directory, navigate folders, manipulate files, and more.

It’s ideal for navigating code bases from your terminal.

At first, I was sceptic. Why another tool, when tree and ls work well enough?

My problem with ls is that it only works one level deep. In a deeply nested project structure, ls isn’t very helpful.

tree on the other hand gives me a good overview, but it lists everything. In a big project it’s become unusable as the command produces tonnes of output.

broot offers a sane alternative.

broot preview example image from the broot website

broot is fast and never blocks, even when you make it search a big slow disk (any keystroke interrupts the current search to start the next one).

Customize broot

broot works well out of the box, but you can tweak it to your liking.

For example, when you press Enter on a file, broot previews it with xdg-open. On my machine, that’s the Mousepad editor.
You can try to edit the xdg-settings. I set xdg-open to Vim, but that was slow on my computer.

broot has a config file. You can find it by opening broot and then hitting the ? key. The configuration uses the TOML format.

For example, you can use bat as the preview action:

[[verbs]]
name = "view"
invocation = "view"
key = "enter"
execution = "bat {file}"
leave_broot = false
apply_to = "file"

Now, when I hit Enter inside the broot window, the tool will spit out the contents to standard output.

Now what?

Install broot.
broot is a power-tool and proved to be very useful as my daily driver for file navigation.

Further Reading