dirplot 0.1.2__tar.gz → 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {dirplot-0.1.2 → dirplot-0.2.0}/.github/workflows/ci.yml +19 -1
- dirplot-0.2.0/.ipynb_checkpoints/Untitled-checkpoint.ipynb +6 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/CHANGELOG.md +10 -0
- dirplot-0.2.0/Makefile +41 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/PKG-INFO +67 -16
- {dirplot-0.1.2 → dirplot-0.2.0}/README.md +65 -15
- dirplot-0.2.0/TASKS.md~ +25 -0
- dirplot-0.2.0/Untitled.ipynb +90 -0
- dirplot-0.2.0/map.svg +213 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/pyproject.toml +2 -1
- dirplot-0.2.0/src/dirplot/__init__.py +9 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/display.py +51 -31
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/terminal.py +3 -2
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/test_display.py +36 -11
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/test_drawing.py +3 -2
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/test_render.py +60 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/test_terminal.py +11 -0
- dirplot-0.2.0/treemap.png +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/uv.lock +1 -1
- dirplot-0.1.2/Makefile +0 -38
- dirplot-0.1.2/src/dirplot/__init__.py +0 -3
- {dirplot-0.1.2 → dirplot-0.2.0}/.claude/settings.local.json +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.github/dependabot.yml +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.github/workflows/publish.yml +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.gitignore +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.pre-commit-config.yaml +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/.python-version +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/CONTRIBUTING.md +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/LICENSE +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/SECURITY.md +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/docs/dirplot.png +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/scripts/open_terminals.sh +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/__main__.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/colors.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/fonts/JetBrainsMono-Bold.ttf +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/fonts/JetBrainsMono-BoldItalic.ttf +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/fonts/JetBrainsMono-Italic.ttf +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/fonts/JetBrainsMono-Regular.ttf +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/fonts/OFL.txt +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/main.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/py.typed +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/render.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/src/dirplot/scanner.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/__init__.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/conftest.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/example/bar/bar.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/example/bar/baz.json +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/example/foo/foo.md +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/test_cli.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/test_colors.py +0 -0
- {dirplot-0.1.2 → dirplot-0.2.0}/tests/test_scanner.py +0 -0
|
@@ -11,7 +11,7 @@ jobs:
|
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
strategy:
|
|
13
13
|
matrix:
|
|
14
|
-
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
|
|
15
15
|
|
|
16
16
|
steps:
|
|
17
17
|
- uses: actions/checkout@v6
|
|
@@ -36,3 +36,21 @@ jobs:
|
|
|
36
36
|
|
|
37
37
|
- name: Test
|
|
38
38
|
run: uv run pytest --cov=src --cov-report=xml
|
|
39
|
+
|
|
40
|
+
test-windows:
|
|
41
|
+
runs-on: windows-latest
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v6
|
|
45
|
+
|
|
46
|
+
- name: Install uv
|
|
47
|
+
uses: astral-sh/setup-uv@v7
|
|
48
|
+
|
|
49
|
+
- name: Set up Python 3.10
|
|
50
|
+
run: uv python install 3.10
|
|
51
|
+
|
|
52
|
+
- name: Install dependencies
|
|
53
|
+
run: uv sync --all-extras
|
|
54
|
+
|
|
55
|
+
- name: Test
|
|
56
|
+
run: uv run pytest --cov=src --cov-report=xml
|
|
@@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-03-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Support for Windows, incl. full test suite
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Improved README, Makefile
|
|
19
|
+
|
|
10
20
|
## [0.1.2] - 2026-03-06
|
|
11
21
|
|
|
12
22
|
### Fixed
|
dirplot-0.2.0/Makefile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.PHONY: install lint format test coverage clean install-tool check-all publish-test publish help
|
|
2
|
+
|
|
3
|
+
help: ## Show this help
|
|
4
|
+
@grep -E '^[a-zA-Z_-]+:.*##' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf " %-14s %s\n", $$1, $$2}'
|
|
5
|
+
|
|
6
|
+
install: ## Install all dependencies (including extras)
|
|
7
|
+
uv sync --all-extras
|
|
8
|
+
|
|
9
|
+
format: ## Auto-format and fix lint issues
|
|
10
|
+
uv run ruff format src tests
|
|
11
|
+
uv run ruff check --fix src tests
|
|
12
|
+
|
|
13
|
+
lint: ## Run ruff and mypy
|
|
14
|
+
uv run ruff check src tests
|
|
15
|
+
uv run --all-extras mypy src
|
|
16
|
+
|
|
17
|
+
test: ## Run the test suite
|
|
18
|
+
uv run --all-extras pytest
|
|
19
|
+
|
|
20
|
+
coverage: ## Run tests with HTML + terminal coverage report
|
|
21
|
+
uv run --all-extras pytest --cov=src --cov-report=html --cov-report=term
|
|
22
|
+
|
|
23
|
+
check-all: install format lint test clean ## Run format, lint, test, and clean
|
|
24
|
+
@echo "All checks passed!"
|
|
25
|
+
|
|
26
|
+
install-tool: ## Install dirplot as a uv tool (reinstall)
|
|
27
|
+
uv tool install --reinstall .
|
|
28
|
+
|
|
29
|
+
clean: ## Remove build artifacts and caches
|
|
30
|
+
rm -rf dist build *.egg-info
|
|
31
|
+
rm -rf .pytest_cache .mypy_cache .ruff_cache
|
|
32
|
+
rm -rf htmlcov .coverage coverage.xml
|
|
33
|
+
find . -type d -name __pycache__ -exec rm -rf {} +
|
|
34
|
+
|
|
35
|
+
publish-test: ## Build and publish to TestPyPI
|
|
36
|
+
uv build
|
|
37
|
+
uv publish --index testpypi --token $(TEST_PYPI_TOKEN)
|
|
38
|
+
|
|
39
|
+
publish: ## Build and publish to PyPI
|
|
40
|
+
uv build
|
|
41
|
+
uv publish --token $(PYPI_TOKEN)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dirplot
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Static treemap bitmaps for directory trees, displayed as inline terminal images
|
|
5
5
|
Project-URL: Repository, https://github.com/deeplook/dirplot
|
|
6
6
|
License: MIT
|
|
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
19
|
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
21
|
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
21
22
|
Classifier: Topic :: System :: Filesystems
|
|
22
23
|
Classifier: Topic :: Terminals
|
|
@@ -46,12 +47,35 @@ Description-Content-Type: text/markdown
|
|
|
46
47
|
|
|
47
48
|
**dirplot** creates static nested treemap images for directory trees. It can display them in the system image viewer (default, works everywhere) or inline inside the terminal using the [iTerm2 inline image protocol](https://iterm2.com/documentation-images.html) or the [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/) — detected automatically at runtime.
|
|
48
49
|
|
|
49
|
-
Each rectangle represents a file; its **area** is proportional to the file size and its **colour** is determined by the file extension. Directories are shown as labelled, nested containers, mirroring the actual hierarchy.
|
|
50
|
-
|
|
51
50
|

|
|
52
51
|
|
|
52
|
+
## Features
|
|
53
|
+
|
|
54
|
+
- Directories are shown as labelled, nested containers, mirroring the actual hierarchy.
|
|
55
|
+
- Squarified treemap layout — rectangles are as square as possible for easy reading.
|
|
56
|
+
- File area proportional to file size; colour determined by file extension.
|
|
57
|
+
- ~500 known extensions mapped to colours from the [GitHub Linguist](https://github.com/github/linguist) table; unknown extensions get an MD5-stable colour from any Matplotlib colormap.
|
|
58
|
+
- Label colour (black/white) chosen automatically based on background luminance.
|
|
59
|
+
- Output resolution matches the current terminal window pixel size (via `TIOCGWINSZ`), or a custom `WIDTHxHEIGHT`.
|
|
60
|
+
- Van Wijk cushion shading gives tiles a raised 3-D appearance (optional).
|
|
61
|
+
- Display via system image viewer or inline in the terminal (iTerm2 and Kitty protocols, auto-detected).
|
|
62
|
+
- Save output to a PNG file with `--output`.
|
|
63
|
+
- Exclude paths with `--exclude` (repeatable).
|
|
64
|
+
- Works on macOS, Linux, and Windows; WSL2 fully supported.
|
|
65
|
+
|
|
66
|
+
## How It Works
|
|
67
|
+
|
|
68
|
+
1. Scans the directory tree, collecting each file's path, extension, and size in bytes.
|
|
69
|
+
2. Computes a squarified dirplot layout recursively — directories allocate space for their children.
|
|
70
|
+
3. Renders to a PNG via Pillow (PIL) at the exact pixel dimensions of the current terminal window (detected via `TIOCGWINSZ`), or at a custom size when `--size` is given.
|
|
71
|
+
4. Displays via the system image viewer (`open` / `xdg-open`) or inline via an auto-detected terminal graphics protocol (iTerm2 or Kitty).
|
|
72
|
+
|
|
73
|
+
Extension colours come from the [GitHub Linguist](https://github.com/github/linguist) language colour table (~500 known extensions). Unknown extensions fall back to an MD5-stable colour derived from the chosen `--colormap`. File label text is automatically black or white depending on the background luminance.
|
|
74
|
+
|
|
53
75
|
## Installation
|
|
54
76
|
|
|
77
|
+
> **Note:** The recommended install methods below use [uv](https://docs.astral.sh/uv/). See the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/) if you don't have it yet. Alternatively, use `pip install dirplot` to install without uv.
|
|
78
|
+
|
|
55
79
|
```bash
|
|
56
80
|
# As a standalone tool (recommended)
|
|
57
81
|
uv tool install dirplot
|
|
@@ -70,6 +94,10 @@ uv tool install git+https://github.com/deeplook/dirplot
|
|
|
70
94
|
pip install git+https://github.com/deeplook/dirplot
|
|
71
95
|
```
|
|
72
96
|
|
|
97
|
+
## Platform Support
|
|
98
|
+
|
|
99
|
+
This tool has been developed and tested on macOS and is CI-tested on Linux and Windows (Python 3.10+). The default `--show` mode works on all platforms. The `--inline` mode requires a terminal emulator that supports the iTerm2 or Kitty graphics protocol; on Windows, only [WezTerm](https://wezfurlong.org/wezterm/) currently qualifies. WSL2 is treated as Linux and has full support. Feedback and bug reports are welcome — please open an issue on GitHub.
|
|
100
|
+
|
|
73
101
|
## Usage
|
|
74
102
|
|
|
75
103
|
```bash
|
|
@@ -112,6 +140,7 @@ dirplot . --no-cushion
|
|
|
112
140
|
| `--size` | | terminal size | Output dimensions as `WIDTHxHEIGHT` (e.g. `1920x1080`) |
|
|
113
141
|
| `--header/--no-header` | | `--header` | Print info lines before rendering |
|
|
114
142
|
| `--cushion/--no-cushion` | | `--cushion` | Apply van Wijk cushion shading for a raised 3-D look |
|
|
143
|
+
| `--log/--no-log` | | `--no-log` | Use log of file sizes for layout, making small files more visible |
|
|
115
144
|
|
|
116
145
|
## Inline Display
|
|
117
146
|
|
|
@@ -120,24 +149,50 @@ The `--inline` flag renders the image directly in the terminal. The protocol is
|
|
|
120
149
|
| Terminal | Platform | Protocol |
|
|
121
150
|
|---|---|---|
|
|
122
151
|
| [iTerm2](https://iterm2.com/) | macOS | iTerm2 |
|
|
123
|
-
| [WezTerm](https://wezfurlong.org/wezterm/) | macOS, Linux, Windows | iTerm2 |
|
|
152
|
+
| [WezTerm](https://wezfurlong.org/wezterm/) | macOS, Linux, Windows | Kitty & iTerm2 |
|
|
124
153
|
| [Warp](https://www.warp.dev/) | macOS, Linux | iTerm2 |
|
|
125
154
|
| [Hyper](https://hyper.is/) | macOS, Linux, Windows | iTerm2 |
|
|
126
155
|
| [Kitty](https://sw.kovidgoyal.net/kitty/) | macOS, Linux | Kitty |
|
|
127
156
|
| [Ghostty](https://ghostty.org/) | macOS, Linux | Kitty |
|
|
128
157
|
|
|
129
|
-
The default mode (`--show`, no `--inline`) opens the PNG in the system viewer (`open` on macOS, `xdg-open` on Linux) and works in any terminal.
|
|
158
|
+
The default mode (`--show`, no `--inline`) opens the PNG in the system viewer (`open` on macOS, `xdg-open` on Linux, system default on Windows) and works in any terminal.
|
|
130
159
|
|
|
131
|
-
> **
|
|
160
|
+
> **Windows note:** Common Windows shells (PowerShell, cmd, Git Bash) and terminal emulators (Windows Terminal, ConEmu) do not support any inline image protocol. `--inline` will silently produce no output in these environments. [WezTerm](https://wezfurlong.org/wezterm/) is currently the only mainstream Windows terminal emulator that supports inline image rendering (via the Kitty graphics protocol). WSL2 is treated as Linux and has full support.
|
|
132
161
|
|
|
133
|
-
|
|
162
|
+
> **Note:** `--inline` does not work in AI coding assistants such as Claude Code, Cursor, or GitHub Copilot Chat. These tools intercept terminal output as plain text and do not implement any graphics protocol, so the escape sequences are either stripped or displayed as garbage. Use the default `--show` mode (system viewer) or `--output` to save the PNG to a file instead. Or use [Pi](https://pi.dev) where it is easily added as an extension.
|
|
134
163
|
|
|
135
|
-
|
|
136
|
-
2. Computes a squarified dirplot layout recursively — directories allocate space for their children.
|
|
137
|
-
3. Renders to a PNG via Pillow (PIL) at the exact pixel dimensions of the current terminal window (detected via `TIOCGWINSZ`), or at a custom size when `--size` is given.
|
|
138
|
-
4. Displays via the system image viewer (`open` / `xdg-open`) or inline via an auto-detected terminal graphics protocol (iTerm2 or Kitty).
|
|
164
|
+
## Python API
|
|
139
165
|
|
|
140
|
-
|
|
166
|
+
The public API is small — `build_tree`, `create_treemap`, and the display helpers:
|
|
167
|
+
|
|
168
|
+
```python
|
|
169
|
+
from pathlib import Path
|
|
170
|
+
from dirplot.scanner import build_tree
|
|
171
|
+
from dirplot.render import create_treemap
|
|
172
|
+
|
|
173
|
+
# Build the tree and render to a PNG in memory
|
|
174
|
+
root = build_tree(Path("/path/to/project"))
|
|
175
|
+
buf = create_treemap(root, width_px=1920, height_px=1080, colormap="tab20", cushion=True)
|
|
176
|
+
|
|
177
|
+
# Save to disk
|
|
178
|
+
Path("treemap.png").write_bytes(buf.read())
|
|
179
|
+
|
|
180
|
+
# In a Jupyter notebook: display inline as a cell output (no save needed)
|
|
181
|
+
from PIL import Image
|
|
182
|
+
Image.open(buf) # Jupyter renders PIL images automatically via _repr_png_()
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
To open the result in the system image viewer or display it inline:
|
|
186
|
+
|
|
187
|
+
```python
|
|
188
|
+
from dirplot.display import display_window, display_inline
|
|
189
|
+
|
|
190
|
+
buf.seek(0)
|
|
191
|
+
display_window(buf) # system viewer (works everywhere)
|
|
192
|
+
|
|
193
|
+
buf.seek(0)
|
|
194
|
+
display_inline(buf) # inline in terminal (iTerm2 / Kitty / WezTerm)
|
|
195
|
+
```
|
|
141
196
|
|
|
142
197
|
## Development
|
|
143
198
|
|
|
@@ -149,10 +204,6 @@ make test
|
|
|
149
204
|
|
|
150
205
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for full details.
|
|
151
206
|
|
|
152
|
-
## Platform Support
|
|
153
|
-
|
|
154
|
-
This tool has been developed and tested on macOS. Linux should work, and Windows support is untested. Feedback and bug reports from Linux and Windows users are very welcome — please open an issue on GitHub.
|
|
155
|
-
|
|
156
207
|
## License
|
|
157
208
|
|
|
158
209
|
[MIT](LICENSE)
|
|
@@ -9,12 +9,35 @@
|
|
|
9
9
|
|
|
10
10
|
**dirplot** creates static nested treemap images for directory trees. It can display them in the system image viewer (default, works everywhere) or inline inside the terminal using the [iTerm2 inline image protocol](https://iterm2.com/documentation-images.html) or the [Kitty graphics protocol](https://sw.kovidgoyal.net/kitty/graphics-protocol/) — detected automatically at runtime.
|
|
11
11
|
|
|
12
|
-
Each rectangle represents a file; its **area** is proportional to the file size and its **colour** is determined by the file extension. Directories are shown as labelled, nested containers, mirroring the actual hierarchy.
|
|
13
|
-
|
|
14
12
|

|
|
15
13
|
|
|
14
|
+
## Features
|
|
15
|
+
|
|
16
|
+
- Directories are shown as labelled, nested containers, mirroring the actual hierarchy.
|
|
17
|
+
- Squarified treemap layout — rectangles are as square as possible for easy reading.
|
|
18
|
+
- File area proportional to file size; colour determined by file extension.
|
|
19
|
+
- ~500 known extensions mapped to colours from the [GitHub Linguist](https://github.com/github/linguist) table; unknown extensions get an MD5-stable colour from any Matplotlib colormap.
|
|
20
|
+
- Label colour (black/white) chosen automatically based on background luminance.
|
|
21
|
+
- Output resolution matches the current terminal window pixel size (via `TIOCGWINSZ`), or a custom `WIDTHxHEIGHT`.
|
|
22
|
+
- Van Wijk cushion shading gives tiles a raised 3-D appearance (optional).
|
|
23
|
+
- Display via system image viewer or inline in the terminal (iTerm2 and Kitty protocols, auto-detected).
|
|
24
|
+
- Save output to a PNG file with `--output`.
|
|
25
|
+
- Exclude paths with `--exclude` (repeatable).
|
|
26
|
+
- Works on macOS, Linux, and Windows; WSL2 fully supported.
|
|
27
|
+
|
|
28
|
+
## How It Works
|
|
29
|
+
|
|
30
|
+
1. Scans the directory tree, collecting each file's path, extension, and size in bytes.
|
|
31
|
+
2. Computes a squarified dirplot layout recursively — directories allocate space for their children.
|
|
32
|
+
3. Renders to a PNG via Pillow (PIL) at the exact pixel dimensions of the current terminal window (detected via `TIOCGWINSZ`), or at a custom size when `--size` is given.
|
|
33
|
+
4. Displays via the system image viewer (`open` / `xdg-open`) or inline via an auto-detected terminal graphics protocol (iTerm2 or Kitty).
|
|
34
|
+
|
|
35
|
+
Extension colours come from the [GitHub Linguist](https://github.com/github/linguist) language colour table (~500 known extensions). Unknown extensions fall back to an MD5-stable colour derived from the chosen `--colormap`. File label text is automatically black or white depending on the background luminance.
|
|
36
|
+
|
|
16
37
|
## Installation
|
|
17
38
|
|
|
39
|
+
> **Note:** The recommended install methods below use [uv](https://docs.astral.sh/uv/). See the [uv installation guide](https://docs.astral.sh/uv/getting-started/installation/) if you don't have it yet. Alternatively, use `pip install dirplot` to install without uv.
|
|
40
|
+
|
|
18
41
|
```bash
|
|
19
42
|
# As a standalone tool (recommended)
|
|
20
43
|
uv tool install dirplot
|
|
@@ -33,6 +56,10 @@ uv tool install git+https://github.com/deeplook/dirplot
|
|
|
33
56
|
pip install git+https://github.com/deeplook/dirplot
|
|
34
57
|
```
|
|
35
58
|
|
|
59
|
+
## Platform Support
|
|
60
|
+
|
|
61
|
+
This tool has been developed and tested on macOS and is CI-tested on Linux and Windows (Python 3.10+). The default `--show` mode works on all platforms. The `--inline` mode requires a terminal emulator that supports the iTerm2 or Kitty graphics protocol; on Windows, only [WezTerm](https://wezfurlong.org/wezterm/) currently qualifies. WSL2 is treated as Linux and has full support. Feedback and bug reports are welcome — please open an issue on GitHub.
|
|
62
|
+
|
|
36
63
|
## Usage
|
|
37
64
|
|
|
38
65
|
```bash
|
|
@@ -75,6 +102,7 @@ dirplot . --no-cushion
|
|
|
75
102
|
| `--size` | | terminal size | Output dimensions as `WIDTHxHEIGHT` (e.g. `1920x1080`) |
|
|
76
103
|
| `--header/--no-header` | | `--header` | Print info lines before rendering |
|
|
77
104
|
| `--cushion/--no-cushion` | | `--cushion` | Apply van Wijk cushion shading for a raised 3-D look |
|
|
105
|
+
| `--log/--no-log` | | `--no-log` | Use log of file sizes for layout, making small files more visible |
|
|
78
106
|
|
|
79
107
|
## Inline Display
|
|
80
108
|
|
|
@@ -83,24 +111,50 @@ The `--inline` flag renders the image directly in the terminal. The protocol is
|
|
|
83
111
|
| Terminal | Platform | Protocol |
|
|
84
112
|
|---|---|---|
|
|
85
113
|
| [iTerm2](https://iterm2.com/) | macOS | iTerm2 |
|
|
86
|
-
| [WezTerm](https://wezfurlong.org/wezterm/) | macOS, Linux, Windows | iTerm2 |
|
|
114
|
+
| [WezTerm](https://wezfurlong.org/wezterm/) | macOS, Linux, Windows | Kitty & iTerm2 |
|
|
87
115
|
| [Warp](https://www.warp.dev/) | macOS, Linux | iTerm2 |
|
|
88
116
|
| [Hyper](https://hyper.is/) | macOS, Linux, Windows | iTerm2 |
|
|
89
117
|
| [Kitty](https://sw.kovidgoyal.net/kitty/) | macOS, Linux | Kitty |
|
|
90
118
|
| [Ghostty](https://ghostty.org/) | macOS, Linux | Kitty |
|
|
91
119
|
|
|
92
|
-
The default mode (`--show`, no `--inline`) opens the PNG in the system viewer (`open` on macOS, `xdg-open` on Linux) and works in any terminal.
|
|
120
|
+
The default mode (`--show`, no `--inline`) opens the PNG in the system viewer (`open` on macOS, `xdg-open` on Linux, system default on Windows) and works in any terminal.
|
|
93
121
|
|
|
94
|
-
> **
|
|
122
|
+
> **Windows note:** Common Windows shells (PowerShell, cmd, Git Bash) and terminal emulators (Windows Terminal, ConEmu) do not support any inline image protocol. `--inline` will silently produce no output in these environments. [WezTerm](https://wezfurlong.org/wezterm/) is currently the only mainstream Windows terminal emulator that supports inline image rendering (via the Kitty graphics protocol). WSL2 is treated as Linux and has full support.
|
|
95
123
|
|
|
96
|
-
|
|
124
|
+
> **Note:** `--inline` does not work in AI coding assistants such as Claude Code, Cursor, or GitHub Copilot Chat. These tools intercept terminal output as plain text and do not implement any graphics protocol, so the escape sequences are either stripped or displayed as garbage. Use the default `--show` mode (system viewer) or `--output` to save the PNG to a file instead. Or use [Pi](https://pi.dev) where it is easily added as an extension.
|
|
97
125
|
|
|
98
|
-
|
|
99
|
-
2. Computes a squarified dirplot layout recursively — directories allocate space for their children.
|
|
100
|
-
3. Renders to a PNG via Pillow (PIL) at the exact pixel dimensions of the current terminal window (detected via `TIOCGWINSZ`), or at a custom size when `--size` is given.
|
|
101
|
-
4. Displays via the system image viewer (`open` / `xdg-open`) or inline via an auto-detected terminal graphics protocol (iTerm2 or Kitty).
|
|
126
|
+
## Python API
|
|
102
127
|
|
|
103
|
-
|
|
128
|
+
The public API is small — `build_tree`, `create_treemap`, and the display helpers:
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from pathlib import Path
|
|
132
|
+
from dirplot.scanner import build_tree
|
|
133
|
+
from dirplot.render import create_treemap
|
|
134
|
+
|
|
135
|
+
# Build the tree and render to a PNG in memory
|
|
136
|
+
root = build_tree(Path("/path/to/project"))
|
|
137
|
+
buf = create_treemap(root, width_px=1920, height_px=1080, colormap="tab20", cushion=True)
|
|
138
|
+
|
|
139
|
+
# Save to disk
|
|
140
|
+
Path("treemap.png").write_bytes(buf.read())
|
|
141
|
+
|
|
142
|
+
# In a Jupyter notebook: display inline as a cell output (no save needed)
|
|
143
|
+
from PIL import Image
|
|
144
|
+
Image.open(buf) # Jupyter renders PIL images automatically via _repr_png_()
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
To open the result in the system image viewer or display it inline:
|
|
148
|
+
|
|
149
|
+
```python
|
|
150
|
+
from dirplot.display import display_window, display_inline
|
|
151
|
+
|
|
152
|
+
buf.seek(0)
|
|
153
|
+
display_window(buf) # system viewer (works everywhere)
|
|
154
|
+
|
|
155
|
+
buf.seek(0)
|
|
156
|
+
display_inline(buf) # inline in terminal (iTerm2 / Kitty / WezTerm)
|
|
157
|
+
```
|
|
104
158
|
|
|
105
159
|
## Development
|
|
106
160
|
|
|
@@ -112,10 +166,6 @@ make test
|
|
|
112
166
|
|
|
113
167
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for full details.
|
|
114
168
|
|
|
115
|
-
## Platform Support
|
|
116
|
-
|
|
117
|
-
This tool has been developed and tested on macOS. Linux should work, and Windows support is untested. Feedback and bug reports from Linux and Windows users are very welcome — please open an issue on GitHub.
|
|
118
|
-
|
|
119
169
|
## License
|
|
120
170
|
|
|
121
171
|
[MIT](LICENSE)
|
dirplot-0.2.0/TASKS.md~
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## Tasks
|
|
2
|
+
|
|
3
|
+
- [x] Write some function to scan a directory tree and find for each file the path, extension and size in bytes.
|
|
4
|
+
- [x] Write a function that creates a bitmap with a treemap for that information. Make the color by file extension and the size of a rectangle representing a file according to the file size. Use Matplotlib.
|
|
5
|
+
- [x] Write some typer CLI that accepts a root path for which to create the treemap.
|
|
6
|
+
- [x] Save the treemap first in a PNG file.
|
|
7
|
+
- [x] The PNG should have the same aspect ratio as the current terminal window in pixels. Needs some conversion from rows/cells to pixels.
|
|
8
|
+
|
|
9
|
+
- [x] Make small example image and analyse the right margin where one or two pixel columns seem to be missing cause the effect that the outmost rectangle lacks its right line.
|
|
10
|
+
- [x] Add a --size width,height option with a default based on the current terminal size.
|
|
11
|
+
- [x] Chose filename label color like this: black if the file color converted to grayscale is between white and medium gray, else white
|
|
12
|
+
- [x] Use GitHub Linguist color mappings for known file extensions instead of random colormap colors.
|
|
13
|
+
- [x] Add Examples section to --help output.
|
|
14
|
+
- [x] Add a `--header` (default) / `--no-header` option to print text lines before showing the plot inline or saving it.
|
|
15
|
+
- [ ] Brainstorm about creating the same plots but for other types of input data where we have groups of elements, each with some category and size. Which examples would make the most sense? Write result into a file named OTHER_USECASES.md.
|
|
16
|
+
- [ ] Brainstorm about creating the same plots but where the area of a file rectangle represents the age of the last modification, the bigger, the newer so to say. Write result into a file named FILE_AGE.md.
|
|
17
|
+
- [ ] Try accessing remote directories via SSH as input.
|
|
18
|
+
- [ ] Add a feature to take not only local directories as input but also remote repositories like github or gitlab.
|
|
19
|
+
- [ ] Access remote directory trees via SSH using paramiko (incl. size and other attributes).
|
|
20
|
+
- [ ] Support archive files (often compressed) as input, Z, zoo, zip, tar, tgz, tar.gz, tar.xz, txz using zipfile, tarfile, zlib, zoo, py7zr.
|
|
21
|
+
- [ ] Add some option to cap file size and ignore larger files.
|
|
22
|
+
- [ ] Think about creating the images in other formats, especially SVG/PDF.
|
|
23
|
+
- [ ] Add a Features list before the Installation section to the README.md file.
|
|
24
|
+
|
|
25
|
+
|