Skip to main content

Enhanced directory tree visualization tool

Project description

treeout

A Python-based enhanced tree command that displays directory structures with additional features and customization options.

Prerequisites

  • Python 3.8 or higher
  • No additional dependencies required

Overview

treeout is a versatile command-line tool for visualizing directory structures. It provides more features than the standard Windows tree command and offers rich customization for project analysis, documentation, and file management.

Features

  • ๐Ÿ“‚ Detailed directory tree visualization
  • ๐ŸŽจ Colorized output with file type-based coloring
  • ๐Ÿงฉ Custom color schemes via JSON
  • ๐Ÿ“ Optional file size display
  • ๐Ÿ•’ Optional timestamp information
  • ๐Ÿ” Optional Unix-style permissions
  • ๐Ÿงญ Optional Git status markers
  • ๐Ÿ“ฆ Optional archive inspection for ZIP and TAR files
  • ๐Ÿšซ Configurable ignore patterns
  • ๐ŸŽฏ File extension filtering
  • ๐Ÿ”Ž Glob-based file matching
  • ๐Ÿ“„ Text, JSON, XML, YAML, Markdown, and HTML output
  • ๐Ÿงพ Size snapshots for comparing runs
  • โณ Lightweight traversal progress reporting
  • ๐Ÿ“Š Summary statistics
  • ๐ŸŒฒ Depth control and vertical or horizontal layouts

Installation

Install directly from PyPI:

pip install treeout

For local development, you can clone the repository:

git clone https://github.com/soulwax/treeout.git

Then install it from the repository root:

pip install -e . 

This installs the package as editable, creating a global treeout command while local changes are reflected immediately.

Usage

Basic tree view

treeout

Show with colors and file sizes

treeout -c -s

Show everything (including normally ignored directories)

treeout --show-all

Show with file sizes, timestamps, and statistics

treeout -c -s -t --stats

Show only Python and Markdown files

treeout -e py -e md

Show files matching glob patterns

treeout -g "test_*.py" -g "*.md"

Show Unix-style permissions

treeout -p

Show Git status markers

treeout --git-status

Use a custom color config

treeout -c --color-config treeout-colors.json

Example treeout-colors.json:

{
  "file_colors": {
    ".py": "green",
    ".md": "cyan",
    ".json": "red"
  }
}

Write JSON, YAML, XML, Markdown, or HTML

treeout --format json
treeout --format yaml -o project-tree.yaml
treeout --format html -o tree.html

Use a horizontal path layout

treeout --layout horizontal

Compare file sizes between runs

treeout --save-snapshot before.json
treeout --compare-snapshot before.json --save-snapshot after.json -s --stats

Peek inside archives

treeout --inspect-archives --archive-max-entries 20

Show traversal progress

treeout --progress

Command Line Options

Option Description
-d, --max-depth Maximum depth to traverse
-s, --size Show file sizes
-t, --time Show modification times
-p, --permissions Show Unix-style file permissions
-c, --color Colorize output
--color-config JSON file with custom extension color mappings
--git-status Show Git status markers for tracked and untracked paths
-e, --extension Only show files with this extension; repeat or comma-separate values
-g, --glob Only show files matching this glob; repeat or comma-separate values
-f, --format Output format: text, json, xml, yaml, markdown, or html
--layout Layout style: vertical or horizontal
--compare-snapshot Compare file sizes against a previous snapshot JSON file
--save-snapshot Write a file-size snapshot JSON file for future comparison
--inspect-archives Show entries inside supported .zip, .tar, .tar.gz, and .tgz archives
--archive-max-entries Maximum archive entries to show per archive
--progress Report visited directory count to stderr while generating output
--stats Show summary statistics
--no-color Disable color even if supported

Pattern Handling Options

Option Description
-i, --ignore-pattern Additional regex pattern to ignore
-I, --ignore-patterns File containing patterns to ignore
--no-ignore Disable default ignore patterns
--show-all Show all files (same as --no-ignore)

treeout also reads .treeignore from the target directory when default ignore handling is enabled. Patterns are regexes matched against each basename, the same as -i and -I.

Default Ignored Patterns

The following patterns are ignored by default (can be disabled with --no-ignore):

  • .git - Git directory
  • .pytest_cache - Pytest cache
  • .mypy_cache - MyPy cache
  • __pycache__ - Python cache
  • node_modules - Node.js modules
  • .vscode - VSCode settings
  • .idea - IntelliJ settings
  • .vs - Visual Studio settings
  • .venv, venv, env, .env - Virtual environments
  • .tox - Tox testing
  • .coverage - Coverage data
  • .treeignore - Local treeout ignore file
  • .sass-cache - SASS cache
  • .next - Next.js build
  • dist - Distribution directories
  • build - Build directories
  • .*_cache - Any cache directory

Color Coding

When using the -c option, files are color-coded by type:

  • ๐Ÿ”ต Blue - Directories
  • ๐ŸŸข Green - Executable files (.exe, .sh, .py, etc.)
  • ๐ŸŸก Yellow - Symlinks
  • ๐Ÿ’  Cyan - Media files (images, audio, video)
  • ๐ŸŸฃ Magenta - Archives (.zip, .tar, etc.)
  • ๐Ÿ”ด Red - Special files (config files, json, etc.)

Custom color config files support these color names: blue, green, yellow, cyan, magenta, and red.

Output Example

Directory of D:\Project

โ”œโ”€โ”€โ”€README.md [2.5KB] [2024-01-24 15:30]
โ”œโ”€โ”€โ”€setup.py [1.2KB]
โ”œโ”€โ”€โ”€src
โ”‚   โ”œโ”€โ”€โ”€main.py
โ”‚   โ””โ”€โ”€โ”€utils
โ”‚       โ”œโ”€โ”€โ”€helper.py
โ”‚       โ””โ”€โ”€โ”€config.json
โ””โ”€โ”€โ”€tests
    โ””โ”€โ”€โ”€test_main.py

Summary:
Directories: 3
Files: 5
Total size: 15.7KB

Output Files

The command writes the tree to the target directory by default. Text output uses tree.txt; other formats use matching extensions such as tree.json, tree.yaml, tree.xml, tree.md, or tree.html. Override the path with -o.

When using colors, color is only applied to text console output.

Requirements

  • Python 3.8 or higher
  • No additional dependencies required

TODOs

High Priority

  • Rename and publish as a package on PyPI, modify script to be a CLI entry point
  • Add support for custom output formats (JSON, XML, YAML)
  • Add pattern support for file extensions (e.g., show only *.py files)
  • Allow specifying a start directory as command-line argument
  • Add file permission display option (Unix-style)
  • Support for .treeignore file in project root (similar to .gitignore)

Nice to Have

  • Add interactive mode with real-time directory navigation
  • Export to HTML and Markdown
  • Export to PDF
  • Add Git status integration (show modified/untracked files)
  • Support for custom color schemes via config file
  • Add search functionality with glob patterns
  • Add size comparison between different runs
  • Add progress bar for large directories
  • Add option for horizontal tree layout

Future Considerations

  • Add network share/remote filesystem support
  • Create GUI interface with collapsible tree
  • Add plugin system for custom file type handlers
  • Support for archive inspection (peek into zip/tar files)
  • Add multi-language support for output
  • Create system tray monitoring for directory changes

License

GPL-3.0 License, see LICENSE for details.

Credits

This project was inspired by the standard tree command and aims to provide a more feature-rich alternative for Windows users. Feel free to contribute or suggest new features to enhance the tool further.

Contact / Author

For issues, suggestions, or feedback, please contact the author soulwax: mail me; github user: URL TO or create a new issue o n GitHub, or submit a pull request, any feedback is welcome.

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

treeout-0.9.1.tar.gz (29.7 kB view details)

Uploaded Source

Built Distribution

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

treeout-0.9.1-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file treeout-0.9.1.tar.gz.

File metadata

  • Download URL: treeout-0.9.1.tar.gz
  • Upload date:
  • Size: 29.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for treeout-0.9.1.tar.gz
Algorithm Hash digest
SHA256 8a2f7d6a46a8f6f5224b0b1165f9842c82ee0a0d13a89b254835c61a91c789f4
MD5 0adc344e7db17ac4fb56ffac7327fd0b
BLAKE2b-256 3d16383ca2da324a0c646714209ec383637f0226a6f9e88ec93bead895f6a722

See more details on using hashes here.

File details

Details for the file treeout-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: treeout-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for treeout-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 82ca3f02f378685f68c21e0b5fa9a64c9a19c79f24ebb9f00ba0d93bb297b263
MD5 52581c2c52d7d681d216a731515049df
BLAKE2b-256 e9ddee0703cc3a31bb93ccda0aec3b4ef03a7c7c72d1bed8e7f4c6c50fa8d8bb

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