broot Is An Interactive Treeview Directory Navigation Tool For The Command Line

broot

broot is an interactive command line tool written in Rust for navigating directories using a tree view and fuzzy search. It also incorporates a ncdu like disk usage mode.

The tool is inspired by the tree command (which is not interactively searchable though, and doesn't act as a launcher) and the excellent fzf command line fuzzy finder, allowing users to navigate to a directory and locate a particular file with the minimum amount of keystrokes.

It runs on Linux, macOS and Windows. There are some rough edges on Windows though - some things need fixing, and it's quite slow on Windows for now. It works great and it's very fast on Linux though (and I assume macOS, although I don't own a Mac so I didn't try it).

broot fuzzy search

To get started with broot, type br and you'll get a tree overview of a directory. Some items show under "unlisted" so the output is short and easy to navigate. Start typing the name of the directory you want to navigate to - the fuzzy search will filter the available directories, only listing those matching what you type (including those that may have been originally under "unlisted"). If you want to search with a regular expression, add a / before or after the pattern.

Use the Up and Down arrow keys to select a directory. Press Enter to navigate to the selected directory while keeping broot open, Esc to get back to the previous state or clear your search, or Alt + Enter to get back to the shell having cd to the selected directory.

You might like: Starship Is A Minimal And Fast Shell Prompt Written In Rust

Manipulating files/folders using broot

By default, broot tries to select the most relevant file, depending on what you type. After selecting a file in broot, press Enter to open it in the system's default program, Alt + Enter to open it and close broot, or type a verb to manipulate it, like :e to open it with your default editor. You may also manipulate the selected file using :mv (move), :cp (copy), :rm (remove), and create a new directory with :mkdir. You may also add your own shortcuts.

Enabled showing: disk usage, permissions, last modified date

Fuzzy search in broot with the permissions and last modified date shown

broot supports various options for showing file permissions, dates, disk space used, and show or hide hidden files:

  • Hit the Space key and then type s, or type :s (with no space in front of it) to see the size of each file and folder in a directory. The sizes are cached, but you can hit F5 to refresh them
  • Press Space then type d, or type :d to toggle showing the last modified date for each file and directory in the tree
  • Press Space then type pe, or type :pe to toggle showing permissions
  • Press Space and then type h, or type :h to toggle showing hidden files

You can bring up the broot help at any time by pressing ? (Shift + ?).

You may also like: forgit: Interactive Git Commands With Previews Powered By fzf Fuzzy Finder

Broot also has gitignore support, with 3 modes: no (.gitignore files aren't applied), yes (.gitignore rules are applied whenever they're found; if the root contains several git projects, it means different visible subtrees follow different sets of rules), and auto (if the current root is a git directory or inside one, then the rules are applied; otherwise they aren't). You can toggle between these modes by typing :gi.

Edit: with the latest 0.13.0 release, broot has added support for showing the git status. Use :gf and broot will show the status of files (new, modified, etc.), the current branch name and the change statistics.

It's important to note that when you search using broot on a very large / slow disk, the tool stops if it finds enough matches for your search pattern. If you want to go deeper, and search through all existing files you'll need to enable :total_search, which can be triggered using the Ctrl + s.

For more on broot, check out its excellent documentation on https://dystroy.org/broot/

Install broot



The broot installation page has multiple options. You can install broot using cargo from crates.io or from source, from Homebrew or MacPorts. You'll also find precompiled binaries for Linux (x86_64 and armv7 for Raspberry Pi) and Windows 10.

E.g. on Linux you could install broot by downloading the binary and placing it in your $PATH, in /usr/local/bin for example (this command assumes you're in the folder where the broot binary was downloaded):

sudo install broot /usr/local/bin

Once you have the broot binary somewhere in your $PATH, run it with the --install option so it installs the br shell function (this automatically adds a line in your ~/.bashrc or ~/.zshrc file that sources the br function):

broot --install

After this you can start using broot by typing br:

br