A modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules.
A modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules.
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:
ls -l-like view with information about owners, group, file permission, etc. (Unix-only).tree-like output, or a du-like output.LS_COLORS.You can think of erdtree as a little bit of du, tree, find, wc and ls.
…-l, --long and all of its arguments are currently not available on Windows, but support for a Windows variant is planned.
Make sure you have Rust and its toolchain installed.
$ cargo install erdtreeThe 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-11Thereafter:
$ cargo +nightly-2023-06-11 install erdtree$ brew install erdtree$ scoop install erdtree$ pkgin install erdtreeBinaries for common architectures can be downloaded from latest releases.
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 masterOther means of installation to come.
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.
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.tomlOn Windows:
%APPDATA%\erdtree\.erdtree.tomlHere and below is an example of a valid .erdtree.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 1As far as the arguments go there are only three rules you need to be aware of:
.erdtree.toml only accepts long-named arguments without the preceding "--".snake_case and kebap-case works.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/.erdtreercOn Windows:
$ERDTREE_CONFIG_PATH%APPDATA%\erdtree\.erdtreercThe format of a config file is as follows:
erdtree option/argument.# 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.
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.
-f, --follow
Follow symlinksSymlinks 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:
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 formatWhen 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 prefixesAdditionally, 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 fileLastly, if you'd like to omit disk usage from the output:
--suppress-size
Omit disk usage from outputPhysical 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.
du outputIf you want the same exact disk usage reporting as du, you can do the following:
$ erd --layout flat --disk-usage block --no-ignore --hidden --levelor in short-hand
$ erd -y flat -d block -i -.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.
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 outputinverted layout a more traditional tree-like layout where the root node is at the very top of the output.regular layout is a tree with the root node at the bottom of the output for quick information about total disk usage.flat layout is a tree-less output that more closely resembles du.-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
Show hidden files
--no-git
Disable traversal of .git directory when traversing hidden filesHidden 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.
-I, --icons Display file iconsIcons 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.
Directories are fully traversed by default. To limit the maximum depth:
-L, --level <NUM>
Maximum depth to displayLimiting the maximum depth to display will not affect the total disk usage report nor the file count report.
Sometimes empty directories may appear in the output. To remove them:
-P, --prune
Remove empty directories from outputVarious sorting methods are provided:
…--dir-order and --sort aca
No open issues yet, or sync has not completed.