Scripts2026年4月14日·1 分钟阅读

broot — A Better Way to Navigate Directories

broot gives you a tree view of your filesystem with fuzzy search, built-in file operations, git status, and previews — all in the terminal. It replaces the clunky `tree | less` workflow with an interactive alternative.

Introduction

broot is an interactive file tree: it shows a bounded subset of your directory (so a huge repo doesn't hang the terminal), lets you fuzzy-filter, navigate, perform file operations (rm, mv, cp), open files, check disk usage, and respect .gitignore. The br shell wrapper also lets you cd into any directory you highlight by pressing Enter.

With over 12,500 GitHub stars, broot is a favorite for developers who live in the terminal. It's the closest TUI approximation of a modern file explorer (like VS Code's sidebar) while staying fully keyboard-driven.

What broot Does

broot walks your filesystem lazily, intelligently truncating large directories to fit the screen. Type a pattern and broot fuzzy-filters the tree. Press Enter to cd (via br) or open. Verbs (:rm, :mv, :cp, :git_status, :preview, ...) let you act on files without leaving broot. Customization via a TOML config lets you bind your own shortcuts.

Architecture Overview

[broot TUI (crossterm + tui-rs)]
    |
[Walker + truncation]
   shows visible subset of tree
   respects .gitignore by default
    |
[Fuzzy filter]
   as you type, prune to matches
    |
[Verb system]
   :rm, :mv, :cp, :open, :cd, :git_status,
   :preview, :total_size, :sort_by_date, ...
    |
[Preview panel]
   syntax-highlighted file preview
   image preview via kitty graphics
    |
[Shell wrapper `br`]
   enables cd on Enter from inside broot

Self-Hosting & Configuration

# ~/.config/broot/conf.hjson (or conf.toml)
[[verbs]]
name = "edit"
invocation = "edit"
key = "F4"
shortcut = "e"
execution = "$EDITOR {file}"
leave_broot = false

[[verbs]]
name = "git log"
invocation = "glog"
execution = "tig --all -- {file}"
leave_broot = false

[[verbs]]
name = "open in finder"
invocation = "finder"
execution = "open {directory}"
leave_broot = true
# Useful bundled verbs
# Inside broot, type `:verb_name` or its shortcut
# :git_status      Show git status for visible files
# :preview         Toggle preview pane
# :total_size      Compute real disk usage (du-style)
# :sort_by_date    Sort by mtime instead of name
# :filter          Advanced file filter (type, size)
# :rm              Delete (with confirmation)
# :mv new_path     Rename/move
# :cp new_path     Copy

Key Features

  • Bounded tree view — huge directories don't flood your terminal
  • Fuzzy search — incremental pattern filtering across the tree
  • Preview pane — syntax-highlighted file previews, image preview via kitty
  • Git-aware — show changes, respect .gitignore
  • Verb system — compose file operations without leaving the UI
  • br wrapper — Enter cd's into highlighted directory
  • Disk usage view — sort by total size (du-like, fast)
  • Configurable keybinds + custom verbs — integrate your editor, Git TUI, etc.

Comparison with Similar Tools

Feature broot lf nnn yazi ranger
Language Rust Go C Rust Python
View style Tree (collapsible) Miller columns Miller Miller (Yazi) Miller
Preview Built-in + image External Plugin Built-in Plugin
Startup speed Very fast Very fast Fastest Very fast Slower
cd on exit Yes (br) Yes (lfcd) Yes (nnncd) Yes Yes
Best For Tree-style exploration Classic TUI FM Minimal + fast Modern Rust FM Customization

FAQ

Q: broot vs yazi? A: Different paradigms. broot shows a tree (great for "where is this file?"); yazi uses Miller columns (great for cd-heavy workflows). Many devs install both.

Q: Do I need to learn many verbs? A: No — the default ones cover 95% of use. Start with :rm, :mv, :cp, :preview, :git_status. Type ? inside broot for the help screen of all verbs.

Q: Image previews? A: If your terminal supports the kitty graphics protocol (kitty, WezTerm, Ghostty), broot shows images inline. Otherwise it falls back to a file-type icon.

Q: How do I add a key to edit in Neovim? A: Add a verb with execution = "nvim {file}", a key like F4, and leave_broot = false to return to broot after closing.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产