A customizable tree-like directory viewer with filtering, depth control, and statistics
Project description
ltree
ltree is a fast, customizable CLI tool to visualize directory structures in a tree diagram. It features beautiful Rich UI rendering, Nerd Font/Emoji icon support, detailed statistics, and multiple export formats.
>>> ltree .
๐ ltree/
โโโ โ๏ธ LICENSE
โโโ ๐ ltree/
โ โโโ ๐ __init__.py
โ โโโ ๐ cli.py
โ โโโ ๐ constants.py
โ โโโ ๐ core/
โ โ โโโ ๐ __init__.py
โ โ โโโ ๐ config.py
โ โ โโโ ๐ models.py
โ โ โโโ ๐ scanner.py
โ โ โโโ ๐ utils.py
โ โโโ ๐ renderers/
โ โ โโโ ๐ __init__.py
โ โ โโโ ๐ base.py
โ โ โโโ ๐ exporters.py
โ โ โโโ ๐ rich_renderer.py
โ โโโ ๐ themes/
โ โโโ ๐ __init__.py
โ โโโ ๐ emoji.py
โ โโโ ๐ icons.py
โ โโโ ๐ nerd.py
โโโ ๐ ltree-vscode/
โ โโโ ๐ CHANGELOG.md
โ โโโ ๐ eslint.config.mjs
โ โโโ โ๏ธ package-lock.json
โ โโโ โ๏ธ package.json
โ โโโ ๐ README.md
โ โโโ ๐ฆ src/
โ โ โโโ ๐ฆ extension.ts
โ โโโ โ๏ธ tsconfig.json
โโโ โ๏ธ pyproject.toml
โโโ ๐ README.md
โโโ ๐งช tests/
โ โโโ ๐ __init__.py
โ โโโ ๐ test_cli.py
โ โโโ ๐ test_config.py
โ โโโ ๐ test_core.py
โ โโโ ๐ test_exporters.py
โ โโโ ๐ test_icons.py
โ โโโ ๐ test_rich_renderer.py
โ โโโ ๐ test_utils.py
โโโ ๐ uv.lock
Summary:
Visible: 7 directories, 35 files
Total : 7 directories, 35 files
Installation
For local development or usage:
# 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 file or folder in the Explorer to generate a tree.
- Multiple Formats: Copy as Text, JSON, or Markdown Blocks (perfect for AI prompts).
- Customizable: Pass any CLI arguments directly from VS Code.
To use it, check the ltree-vscode directory for installation instructions.
Usage
ltree [path] [options]
Basic Commands
# Display current directory structure
ltree
# Output to console with color
ltree . -o - --color
# Save tree to a file
ltree /path/to/dir -o tree.txt
# For more help
ltree --help
Quick Examples
Click to expand examples
- Export to JSON:
ltree -F json -o data.json - Markdown List:
ltree -F md -o report.md - Markdown Block:
ltree -F block -o report.md - Limit Depth:
ltree -L 2 --show-ellipsis - Filter by Extension:
ltree --ex-ext .log --ex-ext .tmp - Filter by Regex:
ltree --re-ex "test_.*\.py" - Only Directories:
ltree -d --dirs-first - Show Sizes:
ltree -s -H - Nerd Fonts and Rich UI:
ltree . -F rich --theme nerd
Options
Run ltree --help to see the full list of available options.
View Full Parameter List
Basic Options
| Argument | Short | Default | Description |
|---|---|---|---|
start_path |
. |
Starting directory path. | |
--output |
-o |
- |
Output file name. Use - for stdout. |
Output Formatting & Display
| Argument | Short | Default | Description |
|---|---|---|---|
--format |
-F |
text |
Choices: text, json, md, markdown, block, rich. |
--theme |
emoji | Icon theme to use. Choices: emoji, nerd, none. | |
--color |
-c |
Enable colored output. | |
--size |
-s |
Show file/directory sizes. | |
--human |
-H |
Show size in human-readable format (e.g., 1K, 2M). |
Filtering Rules
| Argument | Short | Description |
|---|---|---|
--all |
-a |
Show hidden files and directories (starting with .). |
--dirs-only |
-d |
Only display directories. |
--ex-dirs |
Exclude specific directories. | |
--ex-files |
-I |
Exclude files (supports wildcards like *.log). |
--ex-ext |
Exclude by file extension (e.g., .log). |
|
--ex-prefix |
Exclude items by prefix. | |
--re-ex |
Exclude paths matching a regular expression. | |
--no-ignore |
Disable automatic exclusion based on .gitignore (enabled by default). | |
--add-dirs |
Re-include specific directories previously excluded. | |
--add-files |
Re-include specific files previously excluded. |
Display Options
| Argument | Short | Description |
|---|---|---|
--max-depth |
-L |
Limit directory recursion depth. |
--full-path |
-f |
Print the full path prefix for every entry. |
--dirs-first |
List directories before files. | |
--show-ellipsis |
Show "..." when depth is truncated. |
Configuration
You can save your favorite settings in a config file so you don't have to type them every time. ltree will automatically search for these files in your project directory (or climb up to find them):
.ltreerc(JSON)pyproject.toml(under[tool.ltree])
Configuration Priority
Settings are merged and overridden in the following order (from highest to lowest priority):
- Command Line Arguments
- Local Configuration File (
.ltreercorpyproject.toml) - Default Settings
Examples
.ltreerc (JSON)
Create a .ltreerc file in your project root:
{
"theme": "nerd",
"size": true,
"human": true,
"dirs_first": true,
"ex_dirs": ["dist", "build", "target"],
"ex_ext": [".log", ".tmp"]
}
pyproject.toml (TOML)
Create a pyproject.toml file in your project root:
[tool.ltree]
theme = "emoji"
full_path = true
color = true
size = true
add_dirs = ["output", "temp"]
Supported Configuration Keys
All command-line flags can be configured in your settings file:
- Booleans & Strings:
- theme: "emoji", "nerd", or "none"
- color, size, human, all (show hidden files), dirs_only, full_path, dirs_first, show_ellipsis, no_ignore
- Filter Rules:
- ex_dirs, ex_files, ex_ext, ex_prefix, add_dirs, add_files
Output Examples
Standard 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
Markdown Mode (-F md)
- ๐ ltree/
- ๐
core.py - ๐
exporters.py
- ๐
- ๐ tests/
- ๐
README.md
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.2.0.tar.gz.
File metadata
- Download URL: ltree_cli-0.2.0.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e46c7a17caf7b074a3c24eff271e14a7548dbc20ebd481f15414e7df5b473612
|
|
| MD5 |
2a6daf98bb33940e6b118f51e7967c82
|
|
| BLAKE2b-256 |
d15342b7350b96dcb468fc7dad5ecdcdddfb76cd5a3d0ab2e3b09edc0ee8a3cf
|
File details
Details for the file ltree_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: ltree_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.17 {"installer":{"name":"uv","version":"0.9.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5e916a93c9b06ce6e1c7aed2e68daebf188d548f767d8194c27b709a5665268
|
|
| MD5 |
947b255a5cd78bc1bcfc7d2185921b1a
|
|
| BLAKE2b-256 |
44fecd950e2bbd20c19783afc345d20c10428a4c69992e938bff8b08bc1eb4a6
|