A command-line file manager

Nimble Tree Climber

© Photo by Kev Kindred on Unsplash

© Photo by Kev Kindred on Unsplash

Article from Issue 250/2021
Author(s):

The broot file manager guarantees clearer, quicker navigation of the directory tree at the command line.

You most likely use a file manager daily to do a variety of tasks from navigating the filesystem to creating, deleting, moving, and copying files. File managers come in many shapes and sizes, from command-line-only tools to the many Norton Commander clones (e.g., Midnight Commander) to graphical tools such as Dolphin (KDE), Nautilus (Gnome), Thunar (Xfce), or PCManFM (LXDE). In particular, if you have ever had to work with Windows Explorer, you will probably appreciate a good file manager.

Amongst the plethora of file managers, broot (pronounced "be root") clearly stands out from the competition in terms of functionality. Broot, an interactive file manager for the command line written in Rust, offers an innovative concept. It replaces commands such as ls and tree with an interactive display.

Copied from tree

Broot is maintained on GitHub [1] and works on Linux, Raspberry Pi OS, macOS, and Windows. Even in very large directories, this nimble file manager provides the user with a better and quicker overview. In principle, broot's display is based on the output from the tree command (Figure 1). However, broot displays the directory tree in a more compact way and makes the display interactive, in contrast to tree. You can search broot's tree display at lightning speed using fzf [2], a fuzzy search tool.

Figure 1: While broot only partially expands large directories, it tells you how many files or directories are unlisted in the current tree view.

Setup

In addition to the GitHub repo, the developers maintain a project website that also provides instructions for broot's installation [3] and configuration. On this site, you also will find binary packages for Android, Linux, Linux with musl, Raspberry Pi, and Windows 10.

You can also find broot in the package archives of Alpine Linux, Arch Linux, Manjaro, Solus, Void Linux, and the BSD derivatives NetBSD and FreeBSD. However, be warned that some of these versions are partially outdated [4]. For distributions with deb package management, a third-party repository offers broot along with other interesting applications [5]. There is also a deb package available without a repository [6], but you must handle the updates manually if you go this route. This deb package works for testing purposes and removes the need to integrate the key for third-party repositories, a feature that Debian recently made less user-friendly [7].

For a permanent installation, I advise building broot yourself from source (Listing 1). To do this, you need a Rust development environment [8], which will give you the latest version. Broot stores its configuration in your home directory in ~/.config/broot/conf.hjson; see the website [3] for a detailed description.

Listing 1

Building broot

$ git clone https://github.com/Canop/broot.git
$ cargo install --path .

Retrofit

When you first launch broot, it asks if it can retrofit the br shell function (Figure 2). You will want to allow this since it lets you use the cd command to change directories inside broot. In the future, you can simply start broot with the br command, followed by the path of the directory you want to view. If you save the path specification, the tool displays the contents of the current working directory.

Figure 2: On the first launch after installation, broot asks if you agree to set up broot as a shell function. Enter Y to agree to this.

While inspired by the tree command, there are some differences. If you compare the output of tree and broot side by side, you will notice that broot displays the same directory more compactly because it doesn't open all the directories immediately (Figure 3). You can navigate the tree at the keyboard and then press Enter to open a directory. In many terminals, you can also double-click to do this. To go back, press Esc.

Figure 3: One look at the respective scrollbars for tree (left) and broot (right) highlights the difference between the two commands.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Command Line: tree

    The tree command can provide a clear view of all your files and directories and offers a few advantages over the usual ls command.

  • Ncdu

    Ncdu adds some GUI-like features to the classic du command.

  • Czkawka

    Czkawka helps find and remove duplicate and obsolete files to free up valuable disk space.

  • Sunflower File Manager

    Sunflower is a highly configurable graphical file manager with two windows that implement an unusual concept by trying to integrate the command line with the file manager.

  • Command Line: Archives

    Gzip and bzip2 not only compress files, they also provide lean and powerful tools for viewing, searching, and comparing text files.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News