Skip to main content

A tree view command-line utility that filters files/folders based on a .gitignore

Project description

TreeIgnore

PyPI version License: MIT

TreeIgnore is a Python command-line utility that prints a tree-style view of the current directory while ignoring files and folders specified in a .gitignore file located at the base folder.

Features

  • Recursive Listing: Displays the directory tree recursively.
  • Gitignore Filtering: Reads the .gitignore file from the base folder to filter out files and folders.
  • Easy to Use: A simple command-line tool that can be executed from any directory.
  • AI-Friendly Output: Perfect for AI tools and LLMs by providing clean project structure without noise from build artifacts, dependencies, or cache files that would unnecessarily consume context windows.

Why TreeIgnore?

TreeIgnore is particularly valuable when working with AI tools and Large Language Models (LLMs). By respecting .gitignore patterns, it provides a clean, focused view of your project's actual source code and important files, filtering out:

  • Build artifacts and cache directories
  • Dependencies and virtual environments
  • IDE configuration files
  • System-specific files

This focused output helps prevent context window bloat when sharing project structures with AI tools, ensuring they can focus on the relevant code and documentation rather than getting distracted by temporary or generated files.

Installation

Install from PyPI:

pip install treeignore

For development, install directly from the repository:

git clone https://gitlab.com/CochainComplex/treeignore.git
cd treeignore
pip install -e .

Usage

Navigate to the base folder (the folder containing your .gitignore file) and run:

treeignore

The tool will display a tree-style view of your directory, filtering out any files or folders that match the patterns in the .gitignore.

Example Comparison

Here's how a typical Python project looks with the standard tree command:

myproject/
├── .git/
│   ├── HEAD
│   ├── config
│   └── ... (many more files)
├── .pytest_cache/
│   └── ... (cache files)
├── __pycache__/
│   └── main.cpython-39.pyc
├── venv/
│   ├── bin/
│   ├── lib/
│   └── ... (hundreds of files)
├── .gitignore
├── main.py
├── requirements.txt
└── tests/
    ├── __pycache__/
    │   └── test_main.cpython-39-pytest.pyc
    └── test_main.py

And here's the same project with treeignore:

myproject/
├── .gitignore
├── main.py
├── requirements.txt
└── tests/
    └── test_main.py

As you can see, treeignore provides a clean view focusing only on the essential project files, making it perfect for documentation, project sharing, and AI tool interactions.

Development

This project uses modern Python tooling:

  • black for code formatting
  • isort for import sorting
  • mypy for type checking

To set up the development environment:

  1. Create a virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install development dependencies:
pip install -e ".[dev]"
  1. Build the package:
python -m build
  1. Run tests:
python -m pytest

Publishing to PyPI

  1. Build the distribution:
python -m build
  1. Upload to PyPI:
python -m twine upload dist/*

Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Author

Alexander Warth - warth.ai

Links

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

treeignore-0.4.0.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

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

treeignore-0.4.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file treeignore-0.4.0.tar.gz.

File metadata

  • Download URL: treeignore-0.4.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for treeignore-0.4.0.tar.gz
Algorithm Hash digest
SHA256 cc96ea8be57dce42be0e81f9c07ce4b431252d37da246022c7fb9811eff20c91
MD5 1b32ddca30acb9f00de05d633dd6af9d
BLAKE2b-256 c32de1f2d405cd65371c63ea35a64e17ff152faa6294dc5231a2451798d9e575

See more details on using hashes here.

File details

Details for the file treeignore-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: treeignore-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 7.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.13

File hashes

Hashes for treeignore-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f39eba409494a5b969d77f05cfd39bf01a1f68c37dec3ba9a2507cd5b7c161c
MD5 9f84af4b9e489685084266fc9d204ffc
BLAKE2b-256 01a79f7e15f29ed8d01f8affb1fdae15f8f54733c9e5ab77d1729d0669ef287a

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