erdtree (et)
A modern, vibrant, and multi-threaded file-tree visualizer and disk usage analyzer that respects hidden files and .gitignore rules by default i.e. the secret love child of tree and du.
Table of Contents
- Description
- Usage
- Installation
- Info
- Comparisons against similar programs
- Rules for Contributing and Feature Requests
- Special Thanks
- Questions you might have
Description
erdtree is a modern alternative to tree and du in that it:
- offers a minimal and user-friendly CLI
- respects hidden files and .gitignorerules by default
- displays file sizes in human-readable format by default
- leverages parallism to traverse the file-system
- displays files using ANSI colors by default
- supports icons! (checkout the Icons section before using)
If the chosen defaults don't meet your requirements and you don't want to bloat your shell configs with aliases, you can use a configuration file instead.
Usage
erdtree (et) is a multi-threaded filetree visualizer and disk usage analyzer.
Usage: et [OPTIONS] [DIR]
Arguments:
  [DIR]  Root directory to traverse; defaults to current working directory
Options:
  -d, --disk-usage <DISK_USAGE>  Print physical or logical file size [default: logical] [possible values: logical, physical]
  -g, --glob <GLOB>              Include or exclude files using glob patterns
      --iglob <IGLOB>            Include or exclude files using glob patterns; case insensitive
      --glob-case-insensitive    Process all glob patterns case insensitively
  -H, --hidden                   Show hidden files; disabled by default
      --ignore-git               Disable traversal of .git directory when traversing hidden files; disabled by default
  -I, --icons                    Display file icons; disabled by default
  -i, --ignore-git-ignore        Ignore .gitignore; disabled by default
  -l, --level <NUM>              Maximum depth to display
  -n, --scale <NUM>              Total number of digits after the decimal to display for disk usage [default: 2]
  -p, --prefix <PREFIX>          Display disk usage as binary or SI units [default: bin] [possible values: bin, si]
  -P, --prune                    Disable printing of empty branches
  -s, --sort <SORT>              Sort-order to display directory content [possible values: name, size, size-rev]
      --dirs-first               Always sorts directories above files
  -S, --follow-links             Traverse symlink directories and consider their disk usage; disabled by default
  -t, --threads <THREADS>        Number of threads to use [default: 4]
      --suppress-size            Omit disk usage from output; disabled by default
      --size-left                Show the size on the left, decimal aligned
      --no-config                Don't read configuration file
  -h, --help                     Print help (see more with '--help')
  -V, --version                  Print version
Installation
crate.io
- Make sure you have Rust and its toolchain installed.
- $ cargo install erdtree
Homebrew-core
$ brew 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.
Info
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.
erdtree will look for a configuration file in any of these locations:
- $ERDTREE_CONFIG_PATH
- $XDG_CONFIG_HOME/erdtree/.erdtreerc
- $XDG_CONFIG_HOME/.erdtreerc
- $HOME/.config/erdtree/.erdtreerc
- $HOME/.erdtreerc
The format of a config file is as follows:
- Every line is an erdtreeoption/argument.
- Lines starting with #are considered comments and are thus ignored.
Arguments passed to erdtree take precedence. If you have a config that you would like to ignore without deleting you can use --no-config.
Here is an example of a valid config:
$ cat $HOME/.erdtreerc
--level 2
--icons
--scale 3
# You can use the short names too
-s size
Binary prefix or SI Prefix
Disk usage is reported using binary prefixes by default (e.g. 1 KiB = 1024 B) as opposed to SI prefixes (1 KB = 1000 B). To toggle between the two use the -p, --prefix option.
Logical or physical disk usage
Logical sizes are reported by default but you can toggle the reporting to physical sizes which takes into account compression, sparse files, and actual blocks allocated to a particular file via the following option:
-d, --disk-usage <DISK_USAGE>  Print physical or logical file size [default: logical] [possible values: logical, physical]
How are directory sizes computed
- A directory will have a size equal to the sum of the sizes of all of its entries.
- Hidden files, files excluded by .gitignore, and files excluded via globbing will be ommitted from the disk usages of their parent directories.
- Files/Directories that don't have read permissions will be ommitted from the disk usages of their parent directories.
- Special files such a named pipes, sockets, etc. have negligible sizes so their disk usage aren't reported.
Symlinks
- If symlink following is not enabled via -S, --follow-links, the disk usages of their target will not be reported nor considered.
- If symlink following is enabled the size of the target will be reported and considered as part of the total of the symlink's ancestral directories.
- The parts of the file-tree that branch from the symlink that's followed are printed in a different color.
Hardlinks
If you happen to have multiple hardlinks pointing to the same underlying inode in a given file-tree, everything subsequent to the first will be skipped and ignored as to not be double counted in the overall disk-usage.
File coloring
Files are printed in ANSI colors specified according to the LS_COLORS environment variable on GNU/Linux systems. In its absence a default value is used.
Note for MacOS: MacOS uses the LSCOLORS environment variable to determine file colors for the ls command which is formatted very differently from LS_COLORS. MacOS systems will fall back on the aforementioned default value unless the user defines their own LS_COLORS environment variable.
Icons
Icons (enabled with I, --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.
Comparisons against similar programs
tree command
This is not a rewrite of the tree command thus it should not be considered a 1-to-1 port. While the spirit of tree is maintained erdtree there are more differences than there are similarities.
Advantages over exa --tree
Exa is a powerful modern equivalent of the ls command which gives the option to print a tree-view of a specified directory, however the primary differences between exa --tree and et are:
- exa --tree --git-ignoredoesn't respect- .gitignorerules on a per directory basis whereas- etdoes. With- exathe root's- .gitignoreis considered, but if child directories have their own- .gitignorethey are disregarded and all of their contents will be printed.
- etdisplays the total size of a directory as the sum of all of its entries' sizes whereas- exadoes not support this. This makes sorting directories in the tree-view by size dubious and unclear. Below are screenshots comparing equivalent usages of- etand- exa, using long option names for clarity.
exa
erdtree
dua
dua is a fantastic interactive disk usage analyzer that serves as a modern alternative to ncdu. If you're in the mood for something interactive, dua might suit you more. If you'd rather do a quick analysis of your file-tree and disk-usage without spinning up an entire terminal UI then go with erdtree.
dust
dust is another fantastic tool that heavily overlaps with erdtree in functionality. The biggest differences between the two:
- erdtreedefaults to respecting hidden file and- .gitignorerules.
- dustonly shows a limited set of files in the file-tree by default, but also defaults to showing the largest files first.
- erdtreekeeps the spirit of- treewith respect to the output while- dusthas a horizontal bar graph.
I haven't used dust substantially so these are the immediate differences I came across. Try dust and erdtree and see which best suits you.
Rules for Contributing and Feature Requests
Happy to accept contributions but please keep the following in mind:
- If you're doing some minor refactoring and/or code cleanup feel free to just submit a PR.
- If you'd like to add a feature please open up an issue and receive approval first unless you've previously contributed. You can also start a discussion.
- If new arguments/options are added please do your best to keep them sensibly alphabetized.
- The code is heavily documented so please follow suit. cargo doc --opencan be extremely helpful.
- Feature adds generally require tests.
Feature requests in the form of issues in general are welcome.
Special thanks
- to Reddit user /u/johnmfor suggesting that different binary prefixes be colored differently for better visual feedback.
- to Reddit user /u/Freekyfor suggestions on how to handle hardlinks and physical disk sizes.
- to Reddit user /u/lucca_huguet(can be found as luccahuguet on Github) for suggesting that the compilederdtreebinary be shorted toet.
- to all of the lovely people on this Reddit thread who helped shaped erdtreewith their very valuable feedback.
- to messense for getting this on Homebrew-core!
- to all contributors :]
Questions you might have
Q: Why did you make this? It's totally unnecessary.
A: Ennui.
Q: Why is it called erdtree?
A: It's a reference to Elden Ring.
Q: Is it any good?
A: Yes.
Q: Got any testimonials?
Q: Is it blazingly fast?
A: I wrote it in Rust so it should be blazingly fast.