A customizable tree-like directory viewer with filtering, depth control, and statistics
Project description
ltree
ltree is a fast, highly customizable CLI utility used to visualize directory structures in a tree diagram. It features beautiful Rich UI console formatting, robust icon theme support (Nerd Font / Emoji), detailed metrics tracking, and versatile exporters (JSON, YAML, Markdown, HTML, and Graphviz).
>>> ltree tree ltree/core --no-mtime --no-git --no-perm
๐ core/
โโโ ๐ __init__.py
โโโ ๐ config.py
โโโ ๐ filters/
โ โโโ ๐ __init__.py
โ โโโ ๐ base.py
โ โโโ ๐ depth.py
โ โโโ ๐ folders.py
โ โโโ ๐ pipeline.py
โ โโโ ๐ sorting.py
โโโ ๐ metadata/
โ โโโ ๐ __init__.py
โ โโโ ๐ base.py
โ โโโ ๐ code.py
โ โโโ ๐ filesystem.py
โ โโโ ๐ git.py
โ โโโ ๐ models.py
โ โโโ ๐ project.py
โ โโโ ๐ registry.py
โ โโโ ๐ time.py
โโโ ๐ models.py
โโโ ๐ scanners/
โ โโโ ๐ __init__.py
โ โโโ ๐ aggregation.py
โ โโโ ๐ filters.py
โ โโโ ๐ scanner.py
โ โโโ ๐ sorting.py
โ โโโ ๐ subtree.py
โ โโโ ๐ traversal.py
โโโ ๐ utils.py
Summary:
Visible: 3 directories, 26 files
Total : 3 directories, 26 files
Installation
You can install ltree directly from PyPI:
# Using pip
pip install ltree-cli
# Or using uv
uv pip install ltree-cli
For local development or source installations:
# Clone the repository
git clone https://github.com/YuHao-Yeh/ltree.git
cd ltree
# Install in editable mode using uv
uv pip install -e .
# Or using standard pip
pip install -e .
VS Code Extension
ltree now comes with an official VS Code companion!
- Quick Action: Right-click any workspace file or folder in the explorer sidebar to generate a structure diagram.
- Multiple Formats: Select your desired generation format (Markdown List, JSON, Plain Text, or Markdown Code Blocks).
- Customizable: Seamlessly pass any CLI arguments directly from your VS Code Settings or input boxes.
- Convenience: The generated tree diagram will automatically save to your system clipboard for instant sharing.
To get started, check the ltree-vscode directory for detailed installation instructions.
Command-Line Usage
ltree organizes its functionality through logical subcommands.
Run ltree --help to inspect the full list of available subcommands.
1. The tree Subcommand
Generate a directory tree diagram with advanced filtering, metadata inspection, and custom outputs.
[!TIP] Executing
ltreedirectly with a directory path or without any arguments automatically falls back to invoking thetreesubcommand.
# Explicitly generate a tree
ltree tree [path] [options]
# Shortcut fallback (automatically executes the 'tree' subcommand)
ltree [path] [options]
Command Options
Run ltree tree --help to see the full list of available parameters.
View Full Parameter List
Basic Options
| Argument | Short | Default | Description |
|---|---|---|---|
start_path |
. |
Starting directory path. | |
--output |
-o |
- |
Output file name. Use - for standard outout (stdout). |
Formatting & Theme
| Argument | Short | Default | Description |
|---|---|---|---|
--format |
-F |
text |
Output format. Choices: text, json, yaml, md, markdown, block, rich, html, graphviz. |
--theme |
emoji |
Default icon style. Choices: emoji, nerd, none. |
|
--color, --no-color |
-c |
Auto | Toggles ANSI colored output. |
Metadata Flags
| Argument | Short | Description |
|---|---|---|
--perm, --no-perm |
Toggle filesystem permissions (e.g., drwxr-xr-x). Default: active. |
|
--git, --no-git |
Toggle git tracking and modification states. Default: active. | |
--size, --no-size |
-s |
Display file and aggregated directory sizes in bytes. |
--human |
-H |
Formats size displays to human-readable scales (e.g., 1.5 K, 2.0 M). |
--mtime, --no-mtime |
Toggle modification timestamps. Default: active. | |
--code, --no-code |
Toggle lightweight programming language. | |
--project, --no-project |
Toggle configurations parsing for project metadata (e.g., package names and version). |
Filtering & Exclusions
| Argument | Short | Description |
|---|---|---|
--all |
-a |
Process hidden files and directories (starting with .). |
--dirs-only |
-d |
Exclude file entries entirely from visualization layout. |
--exclude |
-I |
Exclude paths matchin literal strings or wildcard patterns (e.g., dist/, *.log). |
--include |
-A |
Re-include paths previously matching an exclusion filter. |
--re-ex |
Exclude paths matching a specific Python regular expression. | |
--gitignore, --no-gitignore |
Toggle automatic evaluation of .gitignore exclusion configurations. |
|
--ex-dirs |
Legacy: Exclude specific directories. | |
--ex-files |
Legacy: Exclude files (supports wildcards like *.log). |
|
--ex-ext |
Legacy: Exclude by file extension (e.g., .log). |
|
--ex-prefix |
Legacy: Exclude items by prefix. | |
--add-dirs |
Legacy: Re-include specific excluded directories. | |
--add-files |
Legacy: Re-include specific excluded files. |
Display Configurations
| Argument | Short | Description |
|---|---|---|
--max-depth |
-L |
Restruct recursive scanning depth to a maximum integer. |
--full-path |
-f |
Print the full relative path prefix instad of just the entry name. |
--dirs-first |
List directories before files. | |
--ellipsis |
Render an ellipsis (...) showing truncated file statisticss on depth-limited branches. |
Examples
# Display current directory structure
ltree tree
# Output to console with color
ltree tree . -o - --color
# Save tree to a file
ltree tree /path/to/dir -o tree.txt
# For more help
ltree tree --help
Quick Configuration Presets
Click to expand configuration presets
| Use Case | Command |
|---|---|
| Export structure as JSON | ltree tree -F json -o data.json |
| Markdown List layout | ltree tree -F md -o report.md |
| Markdown Text Block layout | ltree tree -F block -o report.md |
| Restrict sacn depth | ltree tree -L 2 --ellipsis |
| Filter by Pattern | ltree tree -I *.log -I *.tmp |
| Filter by Regex | ltree tree --re-ex "test_.*\.py" |
| Directories-only Visualization | ltree tree -d --dirs-first |
| File size metrics | ltree tree -s -H |
| Rich + Nerd Fonts | ltree tree . -F rich --theme nerd |
2. The theme Subcommand
Discovers, lists, or previews available icon mappings.
ltree theme [action] [argument]
Actions & Options
Click to expand action details
| Action | Argument | Default | Description |
|---|---|---|---|
list |
Lists all registered icon themes with descriptions. | ||
preview |
theme_name | Renders directory, file, and symlink mockups for a specific theme. Choices: emoji, nerd, none. |
Examples
# Discover what themes are built-in
ltree theme list
# Verify how Nerd Font glyphs render on your terminal environment
ltree theme preview nerd
3. The config Subcommand
Manage configuration files and setting profiles across workspaces.
ltree config [action] [start_path]
Actions & Options
Click to expand action details
| Action | Argument | Default | Description |
|---|---|---|---|
show |
[start_path] | . |
Resolves configurations at start_path (respecting settings hierarchies) and prints active configuration properties. |
locate |
[start_path] | . |
Searches upwards from start_path and prints the locations of discovered .ltreerc or pyproject.toml files. |
validate |
[start_path] | . |
Inspects and validates the formatting syntax of setting profiles found in the recursive path. |
Examples
# Print the merged configuration properties currently in effect.
ltree config show [start_path]
# Trace and locate setting files up through parent directories
ltree config locate [start_path]
# Validate setting syntaxes and formats for setting profiles
ltree config validate [start_path]
Configuration
You can store configuration options in local files to aviod passing them manually on every run. ltree automatically scan upwards for the following configuration targets:
.ltreerc(JSON formatted configuration)pyproject.toml(defined under the[tool.ltree]section)
Precedence Priority
Settings are merged and overridden with the following priority order:
- Command Line Arguments
- Local Configuration File (
.ltreercorpyproject.toml) - Global Default Configurations
Examples
.ltreerc (JSON)
{
"theme": "nerd",
"size": true,
"human": true,
"dirs_first": true,
"exclude": ["dist", "build", "target", "*.log", "*.tmp"]
}
pyproject.toml (TOML)
[tool.ltree]
theme = "emoji"
full_path = true
color = true
size = true
include = ["output", "temp"]
Output Examples
Plain Text (-F text)
ltree/
โโโ ltree/
โ โโโ core.py
โ โโโ exporters.py
โโโ tests/
โโโ README.md
Summary:
Visible: 2 directories, 3 files
Total : 2 directories, 3 files
Rich UI & Nerd Fonts (-F rich --theme nerd)
๏ป ltree/
โโโ ๏ป ltree/
โ โโโ ๎ core.py
โ โโโ ๎ exporters.py
โโโ ๏ tests
โโโ ๏ README.md
Summary:
Visible: 2 directories, 3 files
Total : 2 directories, 3 files
Markdown Lists (-F md)
- ๐ ltree/
- ๐
core.py - ๐
exporters.py
- ๐
- ๐ tests/
- ๐
README.md
System Architecture
ltree is designed as a modular pipeline, where each stage has a single responsibility.
CLI
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Configuration โ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Scanner โ
โ โข Traversal โ
โ โข Filters โ
โ โข Metadata Providers โ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Tree Model โ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Serializer โ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Renderer โ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ Exporter โ
โโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
Console / File
- Configuration โ Resolves command-line arguments and configuration files into a unified
TreeConfig. - Scanner โ Traverses the filesystem, applies filters, and collects metadata.
- Tree Model โ Stores the scanned directory hierarchy in memory.
- Serializer โ Converts the tree model into a renderer-independent representation.
- Renderer โ Produces output in the selected format.
- Exporter โ Writes the rendered output to the console or a file.
Each layer has a single responsibility and can be extended independently, making ltree easy to customize and maintain.
License
Distributed under the MIT License. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ltree_cli-0.3.0.tar.gz.
File metadata
- Download URL: ltree_cli-0.3.0.tar.gz
- Upload date:
- Size: 45.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37c598476f93ed654c6cbd0c4a719f136351af39c1de9c280cca2eb068363f12
|
|
| MD5 |
9fbd2033cbb76cb563c5aefd5598adf9
|
|
| BLAKE2b-256 |
fd8a3e7f925a04ca007675e1f475f2c94487124be1dab809228197ed4f13ced2
|
Provenance
The following attestation bundles were made for ltree_cli-0.3.0.tar.gz:
Publisher:
publish.yml on YuHao-Yeh/ltree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ltree_cli-0.3.0.tar.gz -
Subject digest:
37c598476f93ed654c6cbd0c4a719f136351af39c1de9c280cca2eb068363f12 - Sigstore transparency entry: 2124913394
- Sigstore integration time:
-
Permalink:
YuHao-Yeh/ltree@f89216f9c4fda362b5f5090462af1e4e32ce5507 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/YuHao-Yeh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f89216f9c4fda362b5f5090462af1e4e32ce5507 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ltree_cli-0.3.0-py3-none-any.whl.
File metadata
- Download URL: ltree_cli-0.3.0-py3-none-any.whl
- Upload date:
- Size: 61.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dadbc42ffabd674aefb92f6a46ce7e3b44c06193c9a7339099df92d1933896ed
|
|
| MD5 |
c8d0a7370e912353bc37d8822704b194
|
|
| BLAKE2b-256 |
bf1d8f95b21949d527d57933cbc55399eaab588ee378e85166a3e541aeedc780
|
Provenance
The following attestation bundles were made for ltree_cli-0.3.0-py3-none-any.whl:
Publisher:
publish.yml on YuHao-Yeh/ltree
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ltree_cli-0.3.0-py3-none-any.whl -
Subject digest:
dadbc42ffabd674aefb92f6a46ce7e3b44c06193c9a7339099df92d1933896ed - Sigstore transparency entry: 2124913424
- Sigstore integration time:
-
Permalink:
YuHao-Yeh/ltree@f89216f9c4fda362b5f5090462af1e4e32ce5507 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/YuHao-Yeh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@f89216f9c4fda362b5f5090462af1e4e32ce5507 -
Trigger Event:
push
-
Statement type: