2 min read

Leaves turns disk usage into a terminal treemap

Leaves is a Rust-based terminal disk usage visualizer inspired by WinDirStat and QDirStat, built for remote shells and text-only setups.

Image: Hacker News

Leaves is a new text-mode disk usage analyzer that brings a treemap view to the terminal. Inspired by WinDirStat and QDirStat, it renders files and folders as nested rectangles whose area roughly matches their size, making it easier to spot what is consuming space without a graphical desktop.

The tradeoff is precision. Because the interface works at the level of terminal characters, the layout is necessarily coarser than a GUI tool. But that limitation is also the point: Leaves is meant to work well over remote shell connections and on systems where a graphical environment is unavailable or inconvenient.

Built in Rust, the project can be installed from prebuilt binaries on supported platforms or compiled from source with a Rust toolchain. It also supports Nix for reproducible builds. Once installed, running leaves ~/Documents scans that directory; without an argument, it scans the current one.

By default, the app skips hidden directories and respects patterns from .gitignore and .ignore files. Those rules can be disabled with flags such as -A, -H, -I, and -G, and users can further refine scans with git-style glob overrides.

The interface has three main parts:

Recommended reading

Avito eyes free dating inside its app

  • a title bar with the current path, total size, and file count
  • a collapsible sidebar tree for navigation
  • a central treemap panel showing files and directories as rectangles

Keyboard and mouse controls are both supported. Users can navigate directories with the arrow keys, expand or collapse them with Space, and focus into a directory with Enter. Backspace moves back up, but not above the original scan target.

Leaves also includes a few features aimed at making dense file trees readable. It can summarize deep directories by grouping files with the same extension into one block, controlled by --max-depth. A runtime depth can be adjusted with the + and — keys. There is also an x-ray mode, toggled with x, that groups the top level by file type first and then splits each region by directory.

Color is part of the UI logic. Files are colored by extension using a warm palette, while directories use cooler tones, helping users visually compare similar subtrees across projects. The app supports environment-variable overrides such as LEAVES_COLORS=swap, and ships with four built-in themes: fall, spring, greys, and mono.

The project documentation says the interface can handle millions of files while remaining generally responsive, though switching modes may introduce some delay. It also warns that scanning / should exclude virtual file systems like /dev, /proc, and /sys to avoid misleading results. Symbolic links are ignored, while hard links are not detected and may be double-counted.

Tomas Berg

Computing Editor

Tomas lives in the terminal. He covers chips, laptops, and operating systems with a focus on performance and efficiency. He reads kernel changelogs the way other people read fiction, and he's always on the hunt for the perfect mechanical keyboard switch. If it processes data, Tomas has an opinion on it.

via Hacker News

// Keep reading