Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
E

erdtree

> 开发工具
Open source

A modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules.

2.6K stars0 likes1 views
WebsiteGitHub

About

A modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules.

erdtree (erd)

erdtree is a modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules. The following are some feature highlights:

  • Reports disk usage using a variety of metrics: bytes (logical or physical), blocks (Unix-only), word-count, or line-count.
  • Supports an ls -l-like view with information about owners, group, file permission, etc. (Unix-only).
  • Respects hidden file and gitignore rules by default.
  • Supports regular expressions and glob based searching by file-type.
  • Comes with several layouts: a reverse tree output, a tree-like output, or a du-like output.
  • Granular sorting capabilities.
  • Supports icons.
  • Colorized with LS_COLORS.

You can think of erdtree as a little bit of du, tree, find, wc and ls.

Table of Contents

  • Usage
  • Installation
  • Documentation
    • Configuration file
      • Toml file
      • .erdtreerc
    • Hardlinks
    • Symlinks
    • Disk usage
      • Physical vs logical
      • Matching du output
      • Word and line count
    • Layouts
    • gitignore
    • Hidden files
    • Icons
    • Maximum depth
    • Pruning empty directories
    • Sorting
    • Directories only
    • Long view
    • Regular expressions and globbing
    • Truncating output
    • Redirecting output and colorization
    • Parallelism
    • Completions
    • Same filesystem
  • Comparisons against similar programs
    • exa
    • dua
    • dust
    • fd
  • Rules for contributing
  • Security policy
  • Questions you might have

Usage

…

-l, --long and all of its arguments are currently not available on Windows, but support for a Windows variant is planned.

Installation

crates.io (non-Windows)

Make sure you have Rust and its toolchain installed.

$ cargo install erdtree

crates.io (Windows)

The Windows version relies on some experimental features in order to properly support hard-link detection. If you want to build from crates.io you'll first need to install the nightly toolchain before installing erdtree:

$ rustup toolchain install nightly-2023-06-11

Thereafter:

$ cargo +nightly-2023-06-11 install erdtree

Homebrew-core

$ brew install erdtree

Scoop

$ scoop install erdtree

NetBSD

$ pkgin install erdtree

Releases

Binaries for common architectures can be downloaded from latest releases.

Latest non-release

If you'd like the latest features that are on master but aren't yet included as part of a release:

$ cargo install --git https://github.com/solidiquis/erdtree --branch master

Other means of installation to come.

Documentation

Configuration file

If erdtree's out-of-the-box defaults don't meet your specific requirements, you can set your own defaults using a configuration file.

The configuration file currently comes in two flavors: .erdtreerc (to be deprecated) and .erdtree.toml. If you have both, .erdtreerc will take precedent and .erdtree.toml will be disregarded, but please note that .erdtreerc will be deprecated in the near future. There is no reason to have both.

TOML file

erdtree will look for .erdtree.toml in any of the following locations:

On Unix-systems:

$ERDTREE_TOML_PATH
$XDG_CONFIG_HOME/erdtree/.erdtree.toml
$XDG_CONFIG_HOME/.erdtree.toml
$HOME/.config/erdtree/.erdtree.toml
$HOME/.erdtree.toml

On Windows:

%APPDATA%\erdtree\.erdtree.toml

Here and below is an example of a valid .erdtree.toml:

toml
icons = true
human = true

# Compute file sizes like `du`
# e.g. `erd --config du`
[du]
disk_usage = "block"
icons = true
layout = "flat"
no-ignore = true
no-git = true
hidden = true
level = 1

# Do as `ls -l`
# e.g. `erd --config ls`
[ls]
icons = true
human = true
level = 1
suppress-size = true
long = true

# How many lines of Rust are in this code base?
# e.g. `erd --config rs`
[rs]
disk-usage = "line"
level = 1
pattern = "\\.rs$"

.erdtree.toml supports multiple configurations. The top-level table is the main config that will be applied without additional arguments. If you wish to use a separate configuration, create a named table like du above, set your arguments, and invoke it like so:

$ erd --config du

# equivalent to

$ erd --disk-usage block --icons --layout flat --no-ignore --no-git --hidden --level 1

As far as the arguments go there are only three rules you need to be aware of:

  1. .erdtree.toml only accepts long-named arguments without the preceding "--".
  2. Types are enforced, so numbers are expected to be numbers, booleans are expected to be booleans, strings are expected to be strings, and so on and so forth.
  3. snake_case and kebap-case works.

.erdtreerc

erdtree will look for a configuration file in any of the following locations:

On Linux/Mac/Unix-like:

  • $ERDTREE_CONFIG_PATH
  • $XDG_CONFIG_HOME/erdtree/.erdtreerc
  • $XDG_CONFIG_HOME/.erdtreerc
  • $HOME/.config/erdtree/.erdtreerc
  • $HOME/.erdtreerc

On Windows:

  • $ERDTREE_CONFIG_PATH
  • %APPDATA%\erdtree\.erdtreerc

The format of a config file is as follows:

  • Every line is an erdtree option/argument.
  • Lines starting with # are considered comments and are thus ignored.

Arguments passed to erdtree on the command-line will override those found in .erdtreerc.

Click here for an example .erdtreerc.

If you have a config that you would like to ignore without deleting you can use --no-config.

Hardlinks

If multiple hardlinks that point to the same inode are in the same file-tree, all will be included in the output but only one is considered when computing overall disk usage.

Symlinks

-f, --follow
      Follow symlinks

Symlinks when followed will have their targets (and descendants) counted towards total disk usage, otherwise the size of the symlink itself will be reported. If a symlink's target happens to be in the same file-tree as the symlink itself, the target and its descendants will not be double-counted towards the total disk-usage. When a symlink to a directory is followed all of the box-drawing characters of its descendants will be painted in a different color for better visual feedback:

Disk usage

By default disk usage is reported as the total amount of physical bytes stored on the disk. To get the human-readable form:

-H, --human
      Print disk usage in human-readable format

When using the human-readable form, binary units (e.g. 1 KiB = 1024 B) are reported by default. If you prefer SI units (1 KB = 1000 B) you can use the following:

-u, --unit <UNIT>
      Report disk usage in binary or SI units
      
      [default: bin]

      Possible values:
      - bin: Displays disk usage using binary prefixes
      - si:  Displays disk usage using SI prefixes

Additionally, various other disk usage metrics may be used instead of physical bytes. You have the following metrics available:

-d, --disk-usage <DISK_USAGE>
      Print physical or logical file size
      
      [default: physical]

      Possible values:
      - logical:
        How many bytes does a file contain
      - physical:
        How many actual bytes on disk, taking into account blocks, sparse files, and compression
      - line:
        How many total lines a file contains
      - word:
        How many total words a file contains
      - block:
        How many blocks are allocated to store the file

Lastly, if you'd like to omit disk usage from the output:

--suppress-size
  Omit disk usage from output

Physical vs logical

Physical size takes into account compression, sparse files, and actual blocks allocated to a particular file. Logical size just reports the total number of bytes in a file.

Matching du output

If you want the same exact disk usage reporting as du, you can do the following:

$ erd --layout flat --disk-usage block --no-ignore --hidden --level

or in short-hand

$ erd -y flat -d block -i -.

Word and line count

When opting to report disk usage in either word and line count, unlike wc, erdtree will make no attempt to count the amount of words or lines for files that cannot be encoded as a UTF-8 string such as a JPEG file. For cases such as these the line or total word-count will just appear as empty.

Additionally, the word and line-count of directories are the summation of all of the line/word-counts of its descendents.

Layouts

erdtree comes with four layouts:

-y, --layout <LAYOUT>
      Which kind of layout to use when rendering the output
      
      [default: regular]

      Possible values:
      - regular:  Outputs the tree with the root node at the bottom of the output
      - inverted: Outputs the tree with the root node at the top of the output
      - flat:     Outputs a flat layout using paths rather than an ASCII tree
      - iflat:    Outputs an inverted flat layout with the root at the top of the output
  • The inverted layout a more traditional tree-like layout where the root node is at the very top of the output.
  • The regular layout is a tree with the root node at the bottom of the output for quick information about total disk usage.
  • The flat layout is a tree-less output that more closely resembles du.

gitignore

-i, --no-ignore
      Do not respect .gitignore files

.gitignore is respected by default but can be disregarded with the above argument. .gitignore rules are also respected on a per directory basis, so every directory that is encountered during traversal that has a .gitignore will also be considered.

If .gitignore is respected any file that is ignored will not be included in the total disk usage.

Hidden files

-., --hidden
      Show hidden files

  --no-git
      Disable traversal of .git directory when traversing hidden files

Hidden files ignored by default but can be included with -., --hidden. If opting in to show hidden files .git is included; to exclude it use --no-git.

If hidden files are ignored it will not be included in the total disk usage.

Icons

-I, --icons                      Display file icons

Icons are an opt-in feature because for icons to render properly it is required that the font you have hooked up to your terminal emulator contains the glyphs necessary to properly render icons.

If your icons look something like this:

this means that the font you are using doesn't include the relevant glyphs. To resolve this issue download a NerdFont and hook it up to your terminal emulator.

Maximum depth

Directories are fully traversed by default. To limit the maximum depth:

-L, --level <NUM>
      Maximum depth to display

Limiting the maximum depth to display will not affect the total disk usage report nor the file count report.

Pruning empty directories

Sometimes empty directories may appear in the output. To remove them:

-P, --prune
      Remove empty directories from output

Sorting

Various sorting methods are provided:

…

--dir-order and --sort aca

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustclicommandcommand-linecommand-line-tool

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category开发工具
PricingOpen source

> Related tools

V
VS Code
流行的开源代码编辑器
G
Git
分布式版本控制系统
V
Vite
下一代前端构建工具