DEV Community

Cover image for broot, a new way to browse directories
Denys Séguret
Denys Séguret

Posted on

broot, a new way to browse directories

I always loved the overview you can get from a tree like view. But tree is almost never usable, because it usually generates pages (or hundreds of pages) of output.

tree is also not interactively searchable and of course doesn't act as a launcher.

tree was one of the starting point in the reflection. fzf was another one, I can't live without fuzzy search anymore.

And thus I made broot which I use all the time, which lets me go to any directory or file with a few keystrokes and faster than any other one.

shortcut

It's ready for general consumption, now, but I'm still thirsty for feedback.

broot can be launched with commands, which allows for example non interactive shortcuts like this one:

dcd rulset

If any rust expert is around, I'd love to discuss the code, especially any ideas of micro-optimizations (the development of such a program is all about speed).

GitHub logo Canop / broot

A new way to see and navigate directory trees : https://dystroy.org/broot

Broot

CI MIT Latest Version Chat on Miaou

A better way to navigate directories

Install Broot

Get an overview of a directory, even a big one

br -s

overview

Notice the unlisted?

That's what makes it usable where the old tree command would produce pages of output.

.gitignore files are properly dealt with to put unwanted files out of your way (you can ignore them though, see documentation).

Preview files

Hit ctrl when a file is selected and the preview panel appears.

preview

The preview panel stays synchronized with the selection in tree panels.

Find a directory then cd to it

type a few letters

cd

Hit altenter and you're done.

This way, you can navigate to a directory with the minimum amount of keystrokes, even if you don't exactly remember where it is.

broot is fast and doesn't block (any keystroke interrupts the current search to start the next one).

Most useful keys for this:

Discussion (11)

Collapse
dmfay profile image
Dian Fay

This is neat! I don't know if there's really an "interactive tree"-shaped hole in how I navigate filesystems but it's always fun to see a new take on the basics.

Suggestion: ctrl+j/k to move the cursor down/up for the vi people?

Collapse
dystroy profile image
Denys Séguret Author

Good suggestion. The :q and such should already help vi people (like me) at home.

Collapse
tobiassn profile image
Tobias SN

I am broot.

Collapse
qm3ster profile image
Mihail Malo

Radical, works for me. Added the bash script too.
May I suggest adding the following to cargo.toml?

[profile.release]
lto = true
Collapse
autoferrit profile image
Shawn McElroy

While not in a "tree" structure, why not something like z with fzf. that will allow me to go to or edit a file pretty quickly

Collapse
dystroy profile image
Denys Séguret Author

z ? I'm sorry, I don't see what you refer to (my knowledge of fzf is quite limited).

Collapse
autoferrit profile image
Shawn McElroy • Edited on

theres a tool called z where i can type say z folderName and it will jump to a directory that I have been to in the past with cd. just typing z will show me all the directories I have been to recently, ranked by how often I go to them.

fzf is a pretty terminal ui for finding files (in picture). Though, fzf has a lot of other great uses found here:

github.com/junegunn/fzf
fzf

I was just curious why you didn't use those. But if you were not familiar with them, that makes sense. I could do most of what you do with fzf and z. However, I do really like what you have made here. What I like is the tree like structure. I have installed it and was playing with it earlier. Good work. I'll have to keep it.

Thread Thread
dystroy profile image
Denys Séguret Author

I'm familiar with fzf for finding files, and I used it a lot before to use broot, it's a great tool (and one of those innovations which inspired a lot of other ones). But I didn't knew of z.

Collapse
janpauldahlke profile image
jan paul

nice thing man, although iam not into rust

Collapse
qm3ster profile image
Mihail Malo

What? Why? :O

Collapse
crewsycrews profile image
🎲Danil Rodin🎲

Great work, man! Will try.