Branchix
A lightweight, dependency-free CLI and Python library that prints a readable tree of directories and files. Works on Linux, macOS and Windows.
Install
pip install branchix
Usage
branchix # whole tree of the current directory
branchix -L 2 # limit depth to 2 levels
branchix path/to/dir # another root
branchix -L 2 --save # write to branchix-tree.txt
branchix --save=tree.md # write to a custom file
Example:
.
├── src/
│ └── branchix/
│ ├── __init__.py
│ └── cli.py
├── tests/
└── README.md
3 directories, 3 files
Options
| Option | Description |
|---|---|
PATH |
Root directory (default .) |
-L N, --level N |
Maximum depth (1 = root's children) |
-a, --all |
Include hidden entries (names starting with .) |
-d, --dirs-only |
Show directories only |
-I PATTERN, --ignore PATTERN |
Skip names matching a glob; repeatable (-I node_modules -I "*.pyc") |
--save [FILE] |
Save to a file instead of printing (default branchix-tree.txt) |
--ascii |
Use ASCII characters instead of box-drawing characters |
-V, --version |
Show version |
Notes:
- Directories are listed first, then files, each sorted case-insensitively.
- Symlinks are shown as
name -> targetand are never followed. - Unreadable directories are marked
[unreadable]. - Because
--savetakes an optional value, write--save=FILE(or putPATHfirst) when combining it with a path. - Exit codes:
0success,1runtime/IO error,2invalid usage or path.
Python API
from branchix import TreeOptions, build_tree
result = build_tree(".", TreeOptions(max_depth=2, ignore=("__pycache__",)))
print(result.render())
print(result.stats) # TreeStats(directories=..., files=...)
Development
git clone https://github.com/sonicore-dev/branchix
cd branchix
python -m pip install -e ".[dev]"
pytest
ruff check .
Releasing
- Update
__version__insrc/branchix/__init__.py(single source of truth) and add an entry toCHANGELOG.md. - Commit, tag (
git tag v0.1.0) and push. - Create a GitHub Release; the
Publish to PyPIworkflow builds and uploads.
One-time setup: on PyPI, add a
Trusted Publisher for this repo
(workflow publish.yml, environment pypi), and create the pypi environment
in the GitHub repo settings.
License
MIT
Metadata
Release files for branchix 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| branchix-0.1.0.tar.gz | 8.0 kB | Without provenance | Details for branchix-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| branchix-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for branchix-0.1.0-py3-none-any.whl |
Total release size: 15.5 kB
Release files / branchix-0.1.0.tar.gz
| Download URL | branchix-0.1.0.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4fe2b96b56651df5b1f66c92b35d19133a01505571aaf9ebcccb574a6ff054d9
|
|
BLAKE2b-256 checksum How to use checksums |
92dcf5f2c05686c70d92ee6ea259a300ed1845c1c6e7a8f6fcea074881782350
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Release files / branchix-0.1.0-py3-none-any.whl
| Download URL | branchix-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5fb0f2e1f22ec8e4d577d7977d7582f34169ddc19644970add3dcb2162dcb403
|
|
BLAKE2b-256 checksum How to use checksums |
65543016450ea09af5ae365acc5f1766c7a1401ced117c8c5c03baa68e872568
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.15.2
|
Security for branchix 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.