Linux Tutorials

Install and Use broot for Directory Navigation on Linux

broot is a terminal-based directory navigator that gives you a tree view of your filesystem with built-in search, file preview, and git integration. Think of it as a replacement for tree and ls combined, but interactive – you type to filter, press enter to navigate, and get an instant overview of any directory no matter how deep the hierarchy goes.

Original content from computingforgeeks.com - post 59245

This guide covers installing broot v1.56.1 on Linux, setting up shell integration with the br alias, and using its core features – directory navigation, search, file preview, custom verbs, and git status display. These steps work on Ubuntu, Debian, RHEL, Rocky Linux, AlmaLinux, Fedora, and Arch Linux. The project is actively maintained on GitHub with full documentation at dystroy.org/broot.

Prerequisites

Before you begin, confirm you have the following in place:

  • A Linux system running Ubuntu 24.04/22.04, Debian 13/12, RHEL 10/9, Rocky Linux 10/9, AlmaLinux 10/9, Fedora 42, or Arch Linux
  • A regular user account with sudo privileges
  • Internet access to download packages
  • Bash or Zsh shell (for shell integration)

Step 1: Install broot on Linux

broot can be installed through several methods. Pick the one that fits your setup best.

Method 1: Download the precompiled binary (all distros)

This is the fastest approach and works on any Linux distribution. Download the latest release directly from GitHub:

wget https://github.com/Canop/broot/releases/download/v1.56.1/broot_1.56.1.zip
unzip broot_1.56.1.zip
sudo mv build/x86_64-linux/broot /usr/local/bin/
sudo chmod +x /usr/local/bin/broot

Verify the installation by checking the version:

broot --version

You should see the version number printed:

broot 1.56.1

Method 2: Install with cargo (Rust package manager)

If you have Rust installed, cargo gives you the latest version compiled for your system. First install the build dependencies, then install broot:

On Debian/Ubuntu:

sudo apt install build-essential libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev -y

On RHEL/Rocky/AlmaLinux/Fedora:

sudo dnf install gcc make libxcb-devel -y

Then install broot via cargo:

cargo install --locked broot

Method 3: Install from distro repositories

Some distributions include broot in their package repositories. Note that the packaged version may not be the latest release.

On Arch Linux:

sudo pacman -S broot

On Alpine Linux:

sudo apk add broot

On Gentoo:

sudo emerge broot

Step 2: Set Up Shell Integration (br alias)

broot works best with shell integration. When you run broot for the first time, it offers to install a shell function called br. This function lets broot change your shell’s current directory – something a regular binary cannot do on its own.

Launch broot for the first time:

broot

broot displays a tree view of your current directory and asks if you want to install the br shell function. Type y and press Enter to accept. This adds a function to your shell configuration file (~/.bashrc for Bash or ~/.zshrc for Zsh).

Reload your shell configuration to activate the br function:

source ~/.bashrc

If you use Zsh, source ~/.zshrc instead. From now on, use br instead of broot for all interactive navigation – it enables directory changing and other shell-integrated features. If you’re setting up your Zsh shell for the first time, broot integrates with it cleanly.

Step 3: Navigate Directories with broot

The core use case of broot is fast directory navigation. Launch it in any directory to get an interactive tree view:

br /etc

broot shows a condensed tree view that fits your terminal. Unlike the tree command which dumps thousands of lines for large directories, broot automatically prunes the display to fit your screen. Use these keys to navigate:

  • Arrow keys – move up and down the tree
  • Enter – open a directory (expand it in the tree) or open a file with the default editor
  • Alt+Enter – cd into the selected directory and exit broot (requires br shell function)
  • Backspace – go back to the parent directory
  • Ctrl+Left – go to the parent directory
  • Escape – clear the current filter or quit

To open a specific path directly:

br /var/log

You can also launch broot with flags to control the display. Show hidden files and directory sizes:

br -sdh

The -s flag shows file sizes, -d shows dates, and -h shows hidden files. This is useful when tracking down what’s consuming disk space in a directory.

Step 4: Search and Filter Files in broot

One of broot’s strongest features is instant search. Just start typing while broot is open – it immediately filters the tree to show only matching files and directories. No need to press any key first.

For example, type conf while viewing /etc and broot instantly narrows the tree to show only paths containing “conf”. The search uses fuzzy matching by default, so you don’t need to type the exact name.

broot supports several search modes for different use cases:

  • Fuzzy name search – just type the pattern (default behavior)
  • Regex search – prefix with / (e.g., /\.conf$ to find files ending in .conf)
  • Content search – prefix with c/ to search inside files (e.g., c/listen_address to find files containing that string)
  • Path search – prefix with p/ to match against the full path

Content search is particularly powerful for sysadmin work. Find every config file that references a specific port:

br /etc
c/8080

This searches the content of all files under /etc for the string “8080” and shows only files that match. Much faster than running grep -r when you want to visually browse the results. The search and filter capabilities work well alongside tools like bat for syntax-highlighted file viewing.

Step 5: Preview Files in broot

broot includes a built-in file preview panel that lets you inspect file contents without leaving the navigator. Toggle the preview panel by pressing Ctrl+Right or by typing :preview.

With the preview panel open, navigate to any file and its contents display on the right side of the terminal. broot applies syntax highlighting for common file types, making it easy to read code and config files directly.

You can also open a second panel for side-by-side directory comparison. Press Ctrl+Right again to open a second panel, then navigate independently in each panel. This creates a Norton Commander-style dual-pane layout directly in your terminal.

To close the preview panel, press Ctrl+Left or type :close_preview.

Step 6: Create Custom Verbs and Shortcuts

Verbs are broot’s way of adding custom actions. You type a verb name in the command area (after pressing :) and broot executes the associated command on the selected file or directory.

broot comes with several built-in verbs like :edit, :rm, :cp, :mv, and :mkdir. To use them, select a file and type the verb:

:edit

This opens the selected file in your default editor ($EDITOR environment variable).

To create your own verb, edit the broot configuration file. Open it with:

vi ~/.config/broot/conf.hjson

Add a custom verb in the verbs section. Here’s an example that creates a :tail verb to follow log files:

{
    invocation: tail
    execution: "tail -f {file}"
    leave_broot: true
}

Another useful custom verb copies the full path of a selected file to the clipboard:

{
    invocation: yank
    execution: "echo -n {file} | xclip -selection clipboard"
    leave_broot: false
}

You can also assign keyboard shortcuts to verbs. Add a key field to bind a shortcut:

{
    invocation: terminal
    key: ctrl-t
    execution: "$SHELL"
    set_working_dir: true
    leave_broot: true
}

This binds Ctrl+T to open a terminal session in the currently selected directory. Save the config file and restart broot to apply changes.

Step 7: Use broot Git Integration

broot has built-in git awareness. When you navigate inside a git repository, broot shows the status of each file – modified, staged, untracked, or ignored – directly in the tree view.

Launch broot with the git status flag to see file states:

br -g

Each file gets a two-character git status marker next to its name, matching the format you see with git status --short. Modified files show as M, untracked as ?, and so on.

You can filter the tree to show only modified files by typing :git_diff. This strips away all clean files and gives you a focused view of what changed – useful in large repositories where git status output gets noisy.

To toggle git-ignored files on and off, press Alt+I. By default, broot respects .gitignore rules and hides ignored files, keeping the tree clean.

Step 8: Configure broot Settings

broot stores its configuration in ~/.config/broot/. The main config file is conf.hjson (Hjson format) or conf.toml (TOML format), depending on what was generated during first launch. Open it to customize broot’s behavior:

vi ~/.config/broot/conf.hjson

Here are the most useful settings to adjust:

Default flags – set flags that apply every time broot starts. To always show hidden files, git status, and file sizes:

default_flags: -ghs

Column order – control what metadata columns appear and in what order:

cols_order: [
    mark
    git
    permission
    date
    size
    name
]

File extension colors – assign custom colors to file types for quick visual identification:

ext_colors: {
    log: "gray(12)"
    conf: "yellow"
    sh: "green"
    py: "rgb(200, 100, 50)"
    yml: "cyan"
}

Preview syntax theme – choose the syntax highlighting theme for the preview panel:

syntax_theme: MochaDark

After editing, save the file and relaunch broot. Changes take effect immediately on the next start. If your terminal shell prompt uses a specific color scheme, you can match broot’s theme to keep things consistent.

broot Keyboard Shortcuts Reference

This table lists the most commonly used keyboard shortcuts for quick reference. Knowing these shortcuts makes you significantly faster when navigating large directory trees in the terminal. For a full list of terminal keyboard shortcuts, check our dedicated cheat sheet.

ShortcutAction
Arrow Up/DownMove selection up or down in the tree
EnterOpen directory or file
Alt+Entercd into selected directory and exit broot
BackspaceGo to parent directory
Ctrl+RightOpen preview panel or second panel
Ctrl+LeftClose panel or go to parent
Alt+HToggle hidden files
Alt+IToggle git-ignored files
Ctrl+QQuit broot
:qQuit broot (vim-style)
:editEdit selected file in $EDITOR
:rmDelete selected file or directory
:cp {dest}Copy selected file to destination
:mv {dest}Move selected file to destination
:mkdir {name}Create a new directory
:git_diffShow only git-modified files

Conclusion

You now have broot installed and configured for fast directory navigation on Linux. The combination of tree view, instant search, file preview, and git integration makes it a solid replacement for juggling tree, find, and ls commands during daily sysadmin work. For monitoring your system alongside broot, check out these terminal-based monitoring tools.

Customize the conf.hjson file to match your workflow – add verbs for tasks you repeat often, set default flags for your preferred view, and assign shortcuts to commands you use daily. Check the broot release page for updates and new features.

Related Articles

Fedora Install Fish Shell and Oh My Fish on Fedora Terminal LPIC 101 – Managing Files and Directories on Linux Terminal macos How To Install Nerd Fonts on Linux / macOS macos How To Install PowerShell on macOS

Leave a Comment

Press ESC to close