erdtree

repository·master·Indexed 25 days ago

https://github.com/solidiquis/erdtree

A modern, cross-platform, multi-threaded filesystem and disk-usage utility (erd) serving as a high-performance alternative to du, tree, find, and ls. It features .gitignore awareness, multiple output layouts (regular, inverted, flat, iflat), and configurable disk usage metrics including physical, logical, line, word, and block counts. Supports configuration via .erdtree.toml and .erdtreerc files.

Tokens
6.4K
Snippets
3
Records
47
Agent score
82%

What's inside erdtree

  1. Use erdtree (erd) CLI

    master

    The erd command is a filesystem and disk-usage utility. The basic syntax is:

    erd [OPTIONS] [DIR]

    By default, it traverses the current working directory. You can specify any directory as an argument.

    Common Usage Patterns

    • Human-readable output: Use -H or --human to see sizes in a readable format (e.g., KB, MB, GB).
    • Change layout: Use -y, --layout <LAYOUT> to switch between regular, inverted, flat, or iflat views.
    • Filter by type: Use -t, --file-type <FILE_TYPE> to restrict results to file, dir, or link.
    • Search with patterns: Use -p, --pattern <PATTERN> for regex, or enable --glob / --iglob for glob-based searching.
    erd [OPTIONS] [DIR]
  2. Install erdtree (erd)

    master

    You can install erdtree using several package managers depending on your operating system and preference.

    Using Cargo (Rust)

    Non-Windows:

    $ cargo install erdtree

    Windows: To support hard-link detection, you must use a specific nightly toolchain:

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

    Using Package Managers

    • Homebrew (macOS/Linux): brew install erdtree
    • Scoop (Windows): scoop install erdtree
    • NetBSD: pkgin install erdtree

    Installing from Git (Latest Features)

    To install the latest version from the master branch:

    $ cargo install --git https://github.com/solidiquis/erdtree --branch master
  3. Run erdtree (erd) via CLI

    master
    The erdtree (aliased as erd) tool is a disk usage analyzer that visualizes filesystem hierarchies. It can be executed directly from the command line to generate various tree layouts. The tool supports different rendering engines (Regular, Flat, Inverted, etc.) and can handle ANSI color output based on the terminal context.
  4. Understand Permissions and Class types

    master

    The Permissions struct represents the access rights for a specific entity class.

    Class

    Defines which entity the permissions apply to:

    • User
    • Group
    • Other

    Attribute

    Represents special file system bits:

    • SUID (Set User ID)
    • SGID (Set Group ID)
    • Sticky (Sticky bit)

    PermissionsTriad

    Represents the combination of Read, Write, and Execute bits:

    • Read
    • Write
    • Execute
    • ReadWrite
    • ReadExecute
    • WriteExecute
    • ReadWriteExecute
    • None
  5. Available output layout engines in erdtree

    master

    The erdtree engine uses different layout types to determine how the directory tree or file list is rendered. When working with the engine's API, you can specify one of the following layout variants:

    • Flat: Produces a flat output similar to the du command, without an ASCII tree structure.
    • FlatInverted: Similar to Flat, but the root directory appears at the top of the output.
    • Regular: Produces a tree output where the root directory is at the bottom.
    • Inverted: Produces a tree output where the root directory is at the top (similar to the traditional tree command).
  6. Generate shell completions for erd

    master
    The erd command supports generating shell completion scripts. This is typically triggered via the internal completions context logic, allowing users to enable tab-completion for the CLI in their respective shells.
  7. Configure erdtree using .erdtree.toml

    master

    You can set custom defaults using a .erdtree.toml file. This file supports multiple named configurations (tables), allowing you to invoke specific presets using the --config flag.

    Configuration 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

    Rules for TOML Configuration

    1. Use long-named arguments without the preceding -- (e.g., icons = true instead of --icons).
    2. Types are strictly enforced (numbers, booleans, strings).
    3. Both snake_case and kebab-case are supported.
    4. The top-level table applies to the default command. Named tables can be invoked via erd --config <name>.
    icons = true
    human = true
    
    # Custom preset named 'du'
    [du]
    disk_usage = "block"
    icons = true
    layout = "flat"
    no-ignore = true
    no-git = true
    hidden = true
    level = 1
    # To use the 'du' preset:
    $ erd --config du
  8. Configure erdtree using named tables

    master

    You can group configuration settings into named tables within your .erdtree.toml file. This allows you to define multiple configuration profiles and select one.

    When a named table is specified, erdtree ignores the top-level configuration and uses only the settings within that specific table.

    Example .erdtree.toml structure:

    [default]
    icons = true
    threads = 4
    
    [fast]
    threads = 16
  9. Configure erdtree using .erdtreerc

    master

    The .erdtreerc format is a legacy configuration style where every line is a single erdtree option/argument. Lines starting with # are ignored as comments. Command-line arguments will override values found in this file.

    Note: .erdtreerc is slated for deprecation in favor of .erdtree.toml.

    Configuration 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

    To ignore your config file without deleting it, use the --no-config flag.

  10. Locate and use the .erdtree.toml configuration file

    master

    erdtree uses a .erdtree.toml file for configuration. The tool searches for this file in specific locations depending on your operating system and environment variables.

    Configuration Search Order

    Unix Systems

    1. The path specified in the $ERDTREE_TOML_PATH environment variable.
    2. $XDG_CONFIG_HOME/erdtree/.erdtree.toml
    3. $XDG_CONFIG_HOME/.erdtree.toml
    4. $HOME/.config/erdtree/.erdtree.toml
    5. $HOME/.erdtree.toml

    Windows Systems

    1. The path specified in the $ERDTREE_TOML_PATH environment variable.
    2. %APPDATA%\erdtree\.erdtree.toml

    Configuration Syntax Rules

    • Boolean flags: Setting a key to true (e.g., icons = true) is equivalent to passing the flag --icons. Setting it to false omits the flag entirely.
    • Key-Value pairs: Keys are converted from snake_case to kebab-case. For example, max_threads = 10 in the TOML file becomes the command-line argument --max-threads 10.
    • Tables: You can use TOML tables to define named configuration sets.
  11. Configure erdtree via .erdtreerc config files

    master
    erdtree can be configured using a .erdtreerc file. The contents of this file should consist of command-line arguments (flags and values) that the parser will interpret. Lines starting with # are treated as comments and ignored. The configuration file is searched for in a specific order depending on your operating system.