Chetan-Chinchulkar/cruft
GitHub: Chetan-Chinchulkar/cruft
基于curses的零依赖交互式终端工具,专门扫描并清理Python虚拟环境、node_modules等开发环境缓存,帮助开发者安全回收磁盘空间。
Stars: 0 | Forks: 0
# 🧹 开发环境清理工具
一个交互式终端脚本,用于查找文件系统中的 **Python virtual environments**、**node_modules**、**build artifacts** 以及其他占用空间大的开发环境目录——然后通过简单的复选框 UI 让您选择要删除哪些。
**零外部依赖** — 仅使用 Python 标准库 (`curses`)。适用于 macOS 和 Linux。
## 快速开始
```
# Scan your entire home directory (interactive UI)
python cruft.py
# Scan a specific directory
python cruft.py --path ~/projects
# Dry run — just list what would be deleted, no changes
python cruft.py --dry-run
# Limit search depth (default is 10 levels deep)
python cruft.py --depth 5
```
## TUI 控制
| 按键 | 操作 |
|-----|--------|
| `↑` / `k` | 向上移动光标 |
| `↓` / `j` | 向下移动光标 |
| `Page Up/Down` | 翻页滚动 |
| `Space` | 切换选中状态 |
| `a` | 选择 **全部** |
| `d` | 取消选择 **全部** |
| `Enter` | 确认并删除选中项 |
| `q` / `Esc` | 退出且不删除 |
## 检测内容
| 类别 | 目录名称 |
|----------|----------------|
| **Python** | `venv`, `.venv`, `env`, `__pycache__`, `.mypy_cache`, `.pytest_cache`, `.tox`, `dist`, `build`, `*.egg-info`, … |
| **Node / JS** | `node_modules`, `.npm`, `.yarn`, `.next`, `.nuxt`, `.turbo`, `.parcel-cache`, … |
| **Rust** | `target/` *(仅当同级目录下存在 `Cargo.toml` 时)* |
| **Java / Gradle** | `.gradle`, `.m2` |
| **Ruby** | `.bundle` |
| **General** | `.cache`, `.ruff_cache`, `.DS_Store` |
## 安全性
- **确认提示** — 在 TUI 中按下 `Enter` 后,删除任何文件之前会显示最终的 `Proceed? [y/N]` 提示。
- **`--dry-run` 模式** — 仅打印列表,不实际触碰任何文件。
- 该脚本不会遍历已删除的目录,因此不可能出现重复计数。
## 环境要求
- Python 3.10+
- `curses` 模块 (macOS 和 Linux 上 Python 内置)
标签:Curses, DNS 反向解析, node_modules 清理, Python 脚本, Python 虚拟环境, SOC Prime, TUI, Vue, 交互式 CLI, 开发工具, 开发环境清理, 批量测试, 效率工具, 文件系统扫描, 无外部依赖, 构建产物清理, 磁盘清理工具, 磁盘空间管理, 系统管理员工具, 终端用户界面, 跨平台工具, 逆向工具