Skip to main content

Fast modern CLI to visualize folder structures with filtering, sorting, and JSON/CSV/Markdown exports

Project description

🌳 gettree

gettree logo

A blazing fast, modern directory tree generator with smart ignores, regex filtering, and rich data exports.


Python Version Platforms License PyPI Version

Overview

gettree is a next-generation CLI tool designed to replace the traditional tree command. Built for modern developer workflows, it automatically respects your ignore files, allows complex regex filtering, sorts by size or type, and exports your directory structures into actionable data formats (JSON, CSV, Markdown).

Why gettree?

  • Blazing Fast: Utilizes optimized os.scandir() caching to traverse massive directories in milliseconds without redundant system calls.
  • Smart Ignores: Natively reads .gitignore, .dockerignore, and custom .gettreeignore files.
  • Beautiful UI: Full color support, file-specific emoji icons, and a flicker-free interactive Watch Mode.
  • Data-Ready: Export your folder structures directly to structured JSON or CSV for downstream scripting.

Installation

Available natively via PyPI.

pip install gettree

Or install the latest bleeding-edge version directly from GitHub:

pip install git+https://github.com/ash-kernel/gettree.git

Usage

gettree [PATH] [OPTIONS]

Quick Start

gettree .                                  # Basic tree
gettree . --color --icons --stats          # Full visual experience
gettree . --filter "\.py$"                 # Regex: Show only Python files
gettree . --sort size --size               # Sort by size (largest first)
gettree . --json -o tree.json              # Export structure to JSON
gettree . --markdown -o docs/tree.md       # Export wrapped in Markdown

Options

Display & UI

Flag Description
--color, -c Enable syntax-highlighted colored output.
--icons Show file-specific emoji icons (🐍, 🌐, 📄, etc.).
--size, -s Display human-readable file sizes.
--depth, -d N Limit maximum folder traversal depth.
--fullpath Show absolute paths instead of relative names.
--stats Append a summary block (files, folders, size, scan time).

Output & Export

Flag Description
--json Output as structured, nested JSON.
--csv Export as a flat CSV file (requires -o).
--markdown Wrap standard text output in a markdown code block.
--output, -o FILE Save the generated output to a specific file.

Filtering & Sorting

Flag Description
--filter, -f PAT Filter items using a Regex pattern.
--sort TYPE Sort items by: name, size, or type. [Default: name]
--ignore, -i PAT Add extra ad-hoc patterns to exclude.
--show-ignored Force display of ignored files/folders.

Advanced Modes

Flag Description
--watch, -w Watch Mode: Live-reload the tree every 2s (flicker-free).
--tui TUI Mode: Open a rich, interactive tree view.
--dockerignore Explicitly include .dockerignore patterns.

Ignore Rules

gettree prevents terminal spam by automatically ignoring heavy folders (node_modules, .git, __pycache__) and seamlessly reading your project's ignore rules.

Patterns are loaded and merged from:

  1. .gitignore (Loaded by default)
  2. .gettreeignore (Custom project rules, loaded by default)
  3. .dockerignore (Requires --dockerignore flag)

Example .gettreeignore

*.log
dist/
temp/
secret_keys.json

Configuration

Tired of typing --color --icons every time? Create a persistent configuration file at ~/.config/gettree/config.toml to set your defaults.

Priority Order: CLI Arguments > Config File > Built-in Defaults

# ~/.config/gettree/config.toml

# Ignore Settings
use_gitignore = true
use_gettreeignore = true
use_dockerignore = false
omit_ignored = true

# Display Defaults
color = true       # Always use colors
icons = true       # Always show icons
depth = null       # Max depth (null = unlimited)

(Note: Windows users can create this file at C:\Users\YourName\.config\gettree\config.toml)


Real-World Recipes

Audit a massive project: gettree . --sort size --size --color --depth 3 --stats

Find all TypeScript files & save to Markdown: gettree . --filter ".tsx?$" --markdown -o frontend_structure.md

Monitor an active build directory: gettree ./dist --watch --color --stats


Performance

Thanks to os.scandir() caching and optimized memory handling, gettree is built for speed:

  • Small projects (< 100 files): < 5ms
  • Medium projects (< 1,000 files): 5 - 50ms
  • Massive projects (> 10,000 files): 50 - 500ms

License

Distributed under the MIT License. See LICENSE for more information.


Developed by Ash
GitHubPyPI

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gettree-3.0.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gettree-3.0.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file gettree-3.0.0.tar.gz.

File metadata

  • Download URL: gettree-3.0.0.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for gettree-3.0.0.tar.gz
Algorithm Hash digest
SHA256 08b5b31f46e99c0ba26c1f791ca3e60a6b3549794070551c1c8740bef8eb1c48
MD5 c75fd5fdbc835c16d44101c25c16fa56
BLAKE2b-256 f17175adb25d0c5dc80fbaadb31a7b43bc7e672ad76b6806dc7fd8709f419c89

See more details on using hashes here.

File details

Details for the file gettree-3.0.0-py3-none-any.whl.

File metadata

  • Download URL: gettree-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for gettree-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 205b349cacc8a3ea5621af01c50de5d7b7a8cfd08313a2b78ca504b5b978e383
MD5 a537bc56589576be7fa1b3af1bc15c65
BLAKE2b-256 884a89242c97bebe08ff718250d6c33d01cc5354542b54a99a4cad5cedf053c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page