A Python CLI tool for generating clean directory tree structures.
Project description
๐ฒ Tree Printer
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
โ๏ธ 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:
- Fork the repository
- Create a feature branch
- Make your changes
- Run the test suite
- 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d418c069eb2fc244c4602340ecade7065ab32003b03033842e43ca4b9dd76166
|
|
| MD5 |
46e9e0311938b3353b75800e7b0a3092
|
|
| BLAKE2b-256 |
9f67e3344fa3ca8513719867dedff3b2b87c9eca6cbe58ede5d6879db9d2355e
|
Provenance
The following attestation bundles were made for directory_tree_printer-0.4.1.tar.gz:
Publisher:
release.yml on AmirmasoudCS/Tree-Printer
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
directory_tree_printer-0.4.1.tar.gz -
Subject digest:
d418c069eb2fc244c4602340ecade7065ab32003b03033842e43ca4b9dd76166 - Sigstore transparency entry: 2065001232
- Sigstore integration time:
-
Permalink:
AmirmasoudCS/Tree-Printer@cd0f1e060c7446e931909c3cd16f582a994f09f8 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/AmirmasoudCS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd0f1e060c7446e931909c3cd16f582a994f09f8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file directory_tree_printer-0.4.1-py3-none-any.whl.
File metadata
- Download URL: directory_tree_printer-0.4.1-py3-none-any.whl
- Upload date:
- Size: 11.7 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 |
db505db9944d8bbc5a7a79e80af7f7a2f86ca54c38bb53226ee4d27c1ddcd850
|
|
| MD5 |
f9a8daaabf4d74c10ee001cc53c70f88
|
|
| BLAKE2b-256 |
dcaba1e1e453a6bb283cf1de8bc5008d465c1aa9d50069b8d33c210bc78ef7c3
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
directory_tree_printer-0.4.1-py3-none-any.whl -
Subject digest:
db505db9944d8bbc5a7a79e80af7f7a2f86ca54c38bb53226ee4d27c1ddcd850 - Sigstore transparency entry: 2065001286
- Sigstore integration time:
-
Permalink:
AmirmasoudCS/Tree-Printer@cd0f1e060c7446e931909c3cd16f582a994f09f8 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/AmirmasoudCS
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd0f1e060c7446e931909c3cd16f582a994f09f8 -
Trigger Event:
push
-
Statement type: