Skip to main content

A Python CLI tool for generating clean directory tree structures.

Project description

๐ŸŒฒ Tree Printer

GitHub Release Tests License Python

A lightweight and customizable command-line utility for generating beautiful directory tree structures directly from your terminal.

Tree Printer makes it easy to visualize project layouts, document repositories, create examples for documentation, and inspect filesystem structures with optional icons, metadata, filtering, sorting, and color themes.


โœจ Features

  • ๐ŸŒณ Generate recursive directory trees
  • ๐Ÿ“ Display directories only
  • ๐Ÿ‘๏ธ Show or hide hidden files
  • ๐Ÿšซ Exclude files, directories, or file extensions
  • ๐Ÿ“ Limit recursion depth
  • ๐Ÿ”ค Sort entries by:
    • Name
    • Size
    • Last modified date
  • ๐Ÿ“Š Display file size
  • ๐Ÿ•’ Display modification timestamps
  • ๐ŸŽจ Multiple color themes
  • ๐Ÿ–ผ๏ธ Optional file and folder icons
  • ๐Ÿ“ Export output to text files
  • ๐Ÿšซ Respect .gitignore
  • โšก Fast and lightweight
  • ๐Ÿงช Fully tested with pytest
  • ๐Ÿ”„ Continuous Integration using GitHub Actions

๐Ÿ“ฆ Installation

From PyPI (Recommended)

pip install directory-tree-printer

From source

git clone https://github.com/AmirmasoudCS/Tree-Printer.git

cd Tree-Printer

pip install .

๐Ÿš€ Quick Start

Print the current directory

tp .

Print another directory

tp path/to/project

Print only directories

tp --dirs-only

Show icons

tp --icons

Show file sizes

tp --size

Limit depth

tp --max-depth 2

Save output

tp --output tree.txt

๐Ÿ“– Examples

Basic

tp .
project
โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ main.py
โ”‚   โ””โ”€โ”€ utils.py
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ pyproject.toml

Icons

tp --icons
๐Ÿ“ project
โ”œโ”€โ”€ ๐Ÿ“ src
โ”‚   โ”œโ”€โ”€ ๐Ÿ main.py
โ”‚   โ””โ”€โ”€ ๐Ÿ utils.py
โ”œโ”€โ”€ ๐Ÿ“˜ README.md
โ””โ”€โ”€ โš™๏ธ pyproject.toml

File Sizes

tp --size
README.md (5.8 KB)
main.py (4.2 KB)
config.py (831 B)

Modified Dates

tp --modified
README.md (2026-05-12 18:42)
main.py (2026-05-11 14:30)

Themes

tp --theme sunset

Sunset Theme


โš™๏ธ CLI Options

Option Alias Description
--max-depth -md Limit recursion depth
--show-hidden -sh Include hidden files
--dirs-only -do Show only directories
--exclude-dirs -ed Exclude directories
--exclude-files -ef Exclude files
--exclude-suffixes -es Exclude file extensions
--sort -st Sort by name, size or modified
--size -s Display file sizes
--modified -m Display modified dates
--icons -i Display icons
--theme -th Select a color theme
--no-color -nc Disable colored output
--gitignore -gi Ignore files listed in .gitignore
--output -o Write output to a file
--version -v Show installed version

๐Ÿงช Development

Clone the repository

git clone https://github.com/AmirmasoudCS/Tree-Printer.git

Install development dependencies

pip install -e ".[dev]"

Run the test suite

pytest

Run tests with coverage

pytest --cov=tree_printer --cov-report=term-missing

Build the package

python -m build

Verify the package

python -m twine check dist/*

๐Ÿ“‚ Project Structure

 
โ”œโ”€โ”€ ๐Ÿ“ images
โ”‚   โ””โ”€โ”€ ๐Ÿ–ผ๏ธ themeImage1.png
โ”œโ”€โ”€ ๐Ÿ“ tests
โ”‚   โ”œโ”€โ”€ ๐Ÿ __init__.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ test_cli.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ test_formatter.py
โ”‚   โ””โ”€โ”€ ๐Ÿ test_printer.py
โ”œโ”€โ”€ ๐Ÿ“ tree_printer
โ”‚   โ”œโ”€โ”€ ๐Ÿ __init__.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ cli.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ config.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ file_types.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ formatter.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ icons.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ models.py
โ”‚   โ”œโ”€โ”€ ๐Ÿ printer.py
โ”‚   โ””โ”€โ”€ ๐Ÿ themes.py
โ”œโ”€โ”€ ๐Ÿ“˜ CHANGELOG.md
โ”œโ”€โ”€ โš–๏ธ LICENSE
โ”œโ”€โ”€ ๐Ÿ main.py
โ”œโ”€โ”€ โš™๏ธ pyproject.toml
โ”œโ”€โ”€ ๐Ÿ“˜ README.md
โ””โ”€โ”€ ๐Ÿ“ requirements-dev.txt

๐Ÿ›ฃ๏ธ Roadmap

Future improvements include:

  • Additional export formats
  • Custom icon packs
  • More color themes
  • Configuration file support
  • Improved Windows terminal support
  • Performance improvements for very large directories

Suggestions and pull requests are always welcome.


๐Ÿค Contributing

Contributions, feature requests, and bug reports are welcome.

If you'd like to contribute:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run the test suite
  5. Submit a Pull Request

๐Ÿ“œ Changelog

See CHANGELOG.md for release history.


โš–๏ธ License

This project is licensed under the MIT License.

See LICENSE for details.


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

directory_tree_printer-0.4.1.tar.gz (26.8 kB view details)

Uploaded Source

Built Distribution

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

directory_tree_printer-0.4.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file directory_tree_printer-0.4.1.tar.gz.

File metadata

  • Download URL: directory_tree_printer-0.4.1.tar.gz
  • Upload date:
  • Size: 26.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for directory_tree_printer-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d418c069eb2fc244c4602340ecade7065ab32003b03033842e43ca4b9dd76166
MD5 46e9e0311938b3353b75800e7b0a3092
BLAKE2b-256 9f67e3344fa3ca8513719867dedff3b2b87c9eca6cbe58ede5d6879db9d2355e

See more details on using hashes here.

Provenance

The following attestation bundles were made for directory_tree_printer-0.4.1.tar.gz:

Publisher: release.yml on AmirmasoudCS/Tree-Printer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file directory_tree_printer-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for directory_tree_printer-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 db505db9944d8bbc5a7a79e80af7f7a2f86ca54c38bb53226ee4d27c1ddcd850
MD5 f9a8daaabf4d74c10ee001cc53c70f88
BLAKE2b-256 dcaba1e1e453a6bb283cf1de8bc5008d465c1aa9d50069b8d33c210bc78ef7c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for directory_tree_printer-0.4.1-py3-none-any.whl:

Publisher: release.yml on AmirmasoudCS/Tree-Printer

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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