Convert Figma logo to code with AI

Canop logobroot

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

10,524
230
10,524
211

Top Related Projects

33,285

A simple, fast and user-friendly alternative to 'find'

63,665

:cherry_blossom: A command-line fuzzy finder

23,530

A modern replacement for ‘ls’.

47,483

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

7,602

Terminal file manager

15,354

A VIM-inspired filemanager for the console

Quick Overview

Broot is a command-line file manager and navigation tool designed to enhance productivity when working with directory trees. It provides a fast and intuitive way to explore, search, and manipulate files and directories, offering features like fuzzy search, tree visualization, and customizable keyboard shortcuts.

Pros

  • Fast and efficient navigation through complex directory structures
  • Powerful search capabilities with fuzzy matching and filtering options
  • Customizable interface and keybindings to suit individual preferences
  • Integrates well with other command-line tools and workflows

Cons

  • Learning curve for users accustomed to traditional file managers
  • Limited graphical interface, which may not appeal to all users
  • Requires installation and configuration, unlike built-in file managers
  • Some advanced features may require additional setup or plugins

Getting Started

To install Broot on Unix-like systems (Linux, macOS):

curl -o broot https://dystroy.org/broot/download/x86_64-linux/broot
chmod +x broot
./broot --install

For Windows, download the executable from the official website and run it.

After installation, you can start Broot by typing br in your terminal. Here are some basic commands to get you started:

  • Navigate: Use arrow keys or hjkl (vim-style)
  • Search: Start typing to filter files/directories
  • Open file: Press Enter
  • Go up one level: Press Alt+Up or ..
  • Toggle hidden files: Press Alt+h
  • Quit: Press q or Esc

For more detailed instructions and advanced usage, refer to the official documentation at https://dystroy.org/broot/.

Competitor Comparisons

33,285

A simple, fast and user-friendly alternative to 'find'

Pros of fd

  • Faster search performance, especially for large directories
  • Simpler command-line interface, focused solely on file finding
  • Better integration with other command-line tools due to its Unix philosophy

Cons of fd

  • Limited functionality compared to broot's file management features
  • Lacks interactive mode and tree-like visualization
  • No built-in preview functionality for files

Code Comparison

fd:

fd -e txt
fd -H -I --changed-within 1d

broot:

br
br --sizes --dates --permissions
br --whale-spotting

fd is a simple and fast file finder, while broot is a more comprehensive file manager and explorer. fd excels in quick searches and integrates well with other tools, but broot offers a richer interactive experience with file previews and advanced navigation features. The code examples show fd's focus on search parameters, while broot demonstrates its versatility in displaying file information and custom views.

63,665

:cherry_blossom: A command-line fuzzy finder

Pros of fzf

  • Faster and more lightweight, especially for large directories
  • More versatile, can be used for general-purpose fuzzy finding beyond file navigation
  • Extensive integration with various tools and shells

Cons of fzf

  • Less visual and intuitive for file system navigation
  • Lacks built-in file management features (e.g., delete, move, copy)
  • Requires more setup and configuration for advanced usage

Code Comparison

fzf (basic usage):

find * -type f | fzf > selected

broot (basic usage):

broot

Summary

fzf is a powerful and flexible fuzzy finder that excels in speed and versatility. It's particularly useful for power users who want to integrate fuzzy finding into various aspects of their workflow. However, it requires more setup and isn't as visually intuitive for file system navigation.

broot, on the other hand, is specifically designed for file system navigation and management. It offers a more visual and user-friendly interface out of the box, making it easier for beginners to use. However, it may be slower for very large directories and is less versatile for non-file-related tasks.

The choice between fzf and broot depends on the user's specific needs and preferences. fzf is better for those who prioritize speed and flexibility, while broot is ideal for users who want a more visual and straightforward file navigation tool.

23,530

A modern replacement for ‘ls’.

Pros of exa

  • More focused on being a modern replacement for ls with enhanced features
  • Offers a wider range of color options and icons for file types
  • Provides more detailed file information, including Git status integration

Cons of exa

  • Limited to file listing and doesn't offer advanced file navigation
  • Lacks interactive features for exploring directory structures
  • May have a steeper learning curve for users familiar with traditional ls

Code comparison

exa:

pub fn print_dir(dir: &Dir, options: &Options) -> io::Result<()> {
    let mut files = Vec::new();
    for entry in dir.files() {
        files.push(File::from_dir_entry(entry)?);
    }
    // ... (sorting and filtering logic)
    display_files(&files, options)
}

broot:

pub fn run(state: &mut AppState) -> Result<(), Error> {
    loop {
        state.screen.draw(&state.tree_view)?;
        match state.con.get_key()? {
            Key::Char('q') => break,
            Key::Enter => state.open_selection()?,
            // ... (other key handling)
        }
    }
    Ok(())
}

The code snippets highlight the different focus of each project: exa on file listing and broot on interactive navigation. exa's code shows file processing for display, while broot's code demonstrates its event-driven, interactive nature.

47,483

ripgrep recursively searches directories for a regex pattern while respecting your gitignore

Pros of ripgrep

  • Extremely fast search performance, especially for large codebases
  • Supports various file types and encodings out of the box
  • Respects .gitignore rules by default, improving search relevance

Cons of ripgrep

  • Limited to text search functionality only
  • Lacks advanced file management features
  • No interactive UI for exploring directory structures

Code comparison

ripgrep:

pub fn search<R: io::Read>(reader: R) -> Result<Stats, Error> {
    let mut searcher = SearcherBuilder::new()
        .binary_detection(BinaryDetection::quit(b'\x00'))
        .build();
    searcher.search_reader(&matcher, reader, printer)
}

broot:

pub fn run(state: &mut AppState) -> Result<(), Error> {
    let tree = state.tree.take().unwrap();
    let (selected, cmd) = verbs::execute(state, &tree)?;
    state.tree = Some(tree);
    match cmd {
        Command::Quit => Ok(()),
        _ => run(state),
    }
}

The code snippets demonstrate the core functionality of each tool. ripgrep focuses on efficient text searching, while broot provides a more interactive file browsing experience with additional features like file management and custom commands.

7,602

Terminal file manager

Pros of lf

  • Written in Go, offering cross-platform compatibility and easy installation
  • Lightweight and fast, with minimal resource usage
  • Highly customizable through configuration files and keybindings

Cons of lf

  • Less intuitive for new users compared to broot's visual interface
  • Limited built-in search capabilities
  • Lacks some advanced features like file previews out of the box

Code Comparison

lf (Go):

func (f *Fm) readMarks() error {
    p := filepath.Join(gConfigDir, "marks")
    b, err := ioutil.ReadFile(p)
    if os.IsNotExist(err) {
        return nil
    }
    // ... (additional code)
}

broot (Rust):

pub fn read_verbs() -> Result<Vec<Verb>, ProgramError> {
    let path = config_dir()?.join("verbs.toml");
    if !path.exists() {
        return Ok(Vec::new());
    }
    let content = std::fs::read_to_string(&path)?;
    // ... (additional code)
}

Both projects demonstrate file reading operations for configuration purposes, but use different approaches due to their respective programming languages and design philosophies. lf focuses on simplicity and efficiency, while broot emphasizes user-friendliness and advanced features.

15,354

A VIM-inspired filemanager for the console

Pros of ranger

  • More extensive customization options through Python scripts
  • Richer feature set, including file previews and tabs
  • Longer development history and larger community

Cons of ranger

  • Steeper learning curve due to more complex configuration
  • Slower startup time, especially with many custom scripts
  • Requires Python to be installed

Code comparison

ranger:

class MyCommand(Command):
    def execute(self):
        self.fm.notify("Custom command executed!")

class MyColorScheme(ColorScheme):
    def use(self, context):
        if context.directory:
            return fg.blue, bg.default

broot:

pub fn execute(line: &str) -> Result<(), Error> {
    let parts: Vec<&str> = line.split_whitespace().collect();
    match parts[0] {
        "cd" => change_directory(&parts[1..]),
        "ls" => list_files(&parts[1..]),
        _ => Err(Error::UnknownCommand),
    }
}

Summary

While ranger offers more extensive customization and features, broot provides a simpler, faster alternative with a focus on efficient navigation. ranger is better suited for power users who want deep customization, while broot is ideal for those seeking a lightweight, quick file browser with modern features like fuzzy search.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Broot

Tests MIT Latest Version Chat on Miaou Packaging status

A better way to navigate directories

Complete Documentation - Installation Instructions - Contributing or Getting Help

Get an overview of a directory, even a big one

Hit 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.

As you sometimes want to see gitignored files, or hidden ones, you'll soon get used to the alti and alth shortcuts to toggle those visibilities.

(you can ignore them though, see documentation).

Find a directory then cd to it

type a few letters

cd

Hit altenter and you're back to the terminal in the desired location.

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:

  • the letters of what you're looking for
  • enter on the root line to go up to the parent (staying in broot)
  • enter to focus a directory (staying in broot)
  • esc to get back to the previous state or clear your search
  • ↓ and ↑ may be used to move the selection
  • altenter to get back to the shell having cd to the selected directory
  • alth to toggle showing hidden files (the ones whose name starts with a dot)
  • alti to toggle showing gitignored files
  • :q if you just want to quit (you can use ctrlq if you prefer)

Never lose track of file hierarchy while you search

search

Broot tries to select the most relevant file. You can still go from one match to another one using tab or arrow keys.

You may also search with a regular expression. To do this, add a / before the pattern.

And you have other types of searches, for example searching on file content (start with c/):

content search

You may also apply logical operators or combine patterns, for example searching test in all files except json ones could be !/json$/&c/test and searching carg both in file names and file contents would be carg|c/carg.

Once the file you want is selected you can

  • hit enter (or double-click) to open it in your system's default program
  • hit altenter to open it in your system's default program and close broot
  • hit ctrl→ to preview it (and then a second time to go inside the preview)
  • type a verb. For example :e opens the file in your preferred editor (which may be a terminal one)

blog: a broot content search workflow

Manipulate your files

Most often, when not using broot, you move your files in the blind. You do a few ls before, then your manipulation, and maybe you check after.

You can instead do it without losing the view of the file hierarchy.

mv

Move, copy, rm, mkdir, are built in and you can add your own shortcuts.

Here's chmod:

chmod

Manage files with panels

When a directory is selected, do ctrl→ and you open another panel (you may open other ones, or navigate between them, with ctrl← and ctrl→).

custom colors tree

(yes, colors are fully customizable)

You can for example copy or move elements between panels:

cpp

If you like you may do it Norton Commander style by binding :copy_to_panel to F5 and :move_to_panel to F6.

Preview files

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

preview

preview

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

Broot displays images in high resolution when the terminal supports Kitty's graphics protocol (compatible terminals: Kitty, WezTerm):

kitty preview

Apply a standard or personal command to a file

size

Just find the file you want to edit with a few keystrokes, type :e, then enter.

You can add verbs or configure the existing ones; see documentation.

And you can add shortcuts, for example a ctrl sequence or a function key

Apply commands on several files

Add files to the staging area then execute any command on all of them.

staging mv

Replace ls (and its clones):

If you want to display sizes, dates and permissions, do br -sdp which gets you this:

replace ls

You may also toggle options with a few keystrokes while inside broot. For example you could have typed this -sdp while in broot. Or hit alth and you see hidden files.

Sort, see what takes space:

You may sort by launching broot with --sort-by-size or --sort-by-date. Or you may, inside broot, type a space, then sd, and enter and you toggled the :sort_by_date mode.

When sorting, the whole content of directories is taken into account. So if you want to find on Monday morning the most recently modified files, launch br --sort-by-date ~.

If you start broot with the --whale-spotting option (or its shortcut -w), you get a mode tailored to "whale spotting" navigation, making it easy to determine what files or folders take space.

Sizes, dates, files counts, are computed in the background, you don't have to wait for them when you navigate.

size

And you keep all broot tools, like filtering or the ability to delete or open files and directories.

If you hit :fs, you can check the usage of all filesystems, so that you focus on cleaning the full ones.

fs

Check git statuses:

Use :gf to display the statuses of files (what are the new ones, the modified ones, etc.), the current branch name and the change statistics.

size

And if you want to see only the files which would be displayed by the git status command, do :gs. From there it's easy to edit, or diff, selected files.

gg

From there it's easy to edit, diff, or revert selected files.

blog: use broot and meld to diff before commit

Further Reading

See Broot's web site for instructions regarding installation and usage.