
Product
Introducing Repository Labels and Security Policies
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
A tree view command-line utility that filters files/folders based on a .gitignore
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.
.gitignore
file from the base folder to filter out files and folders.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:
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.
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 .
Navigate to the base folder (the folder containing your .gitignore
file) and run:
treeignore [path] [options]
The tool will display a tree-style view of the specified directory (or the current directory if none is provided), filtering out any files or folders that match the patterns in the .gitignore
files.
Option | Alias | Description |
---|---|---|
--level <num> | -L | Descend only <num> directories deep. |
--dirs-only | -d | List directories only. |
--full-path | -f | Print the full path prefix for each file. |
--all | -a | List all files, including hidden ones (dotfiles). |
--show-perms | -p | Print file permissions (Unix-like systems). |
--show-size | -s | Print file size in bytes. |
--no-indent | -i | Don't print indentation lines. |
--noreport | Omit the final file/directory count report. | |
--no-ignore | Disable .gitignore filtering (show all files). | |
--version | Show version information and exit. | |
path | Optional directory path to list (default: current). |
Basic Usage (Current Directory):
treeignore
List only directories, up to 2 levels deep:
treeignore -L 2 -d
Show all files (including hidden) with full paths:
treeignore -a -f
Show files in a specific directory, ignoring gitignore rules:
treeignore path/to/your/project --no-ignore
tree
vs treeignore
)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.
This project uses modern Python tooling:
black
for code formattingisort
for import sortingmypy
for type checkingTo set up the development environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -e ".[dev]"
python -m build
python -m pytest
python -m build
python -m twine upload dist/*
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.
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)This project is licensed under the MIT License - see the LICENSE file for details. (Current version: 0.5.0)
Alexander Warth - warth.ai
FAQs
A tree view command-line utility that filters files/folders based on a .gitignore
We found that treeignore demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket is introducing a new way to organize repositories and apply repository-specific security policies.
Research
Security News
Socket researchers uncovered malicious npm and PyPI packages that steal crypto wallet credentials using Google Analytics and Telegram for exfiltration.
Product
Socket now supports .NET, bringing supply chain security and SBOM accuracy to NuGet and MSBuild-powered C# projects.