一个生成目录树结构的命令行工具
Project description
dir2prompt
一个简单易用的命令行工具,用于生成目录树结构。
功能特点
- 生成清晰的目录树结构
- 支持排除指定目录或文件
- 支持仅包含指定目录或文件
- 跨平台支持(Windows、macOS、Linux)
- 🆕 智能剪切板支持
- 本地环境:使用系统剪切板
- SSH环境:通过OSC 52转义序列支持远程剪切板
- 自动检测环境并选择最佳复制方法
- 简洁的命令行界面
安装
使用 pip 安装:
pip install dir2prompt
使用方法
基本用法
# 显示当前目录的树结构
dir2prompt .
# 显示指定目录的树结构
dir2prompt /path/to/your/project
高级用法
# 排除特定目录
dir2prompt . --ex node_modules --ex .git
# 仅包含特定目录
dir2prompt /project --in src --in docs
# 组合使用排除和包含
dir2prompt /project --ex __pycache__ --in src --in tests
# 输出到文件
dir2prompt . -o tree.txt
# 复制到剪切板
dir2prompt . -c
# 复制到剪切板并输出到文件
dir2prompt . -c -o tree.txt
命令行选项
path: 要扫描的目录路径--ex, --exclude: 排除的路径(可多次使用)--in, --include: 包含的路径(可多次使用)-o, --output: 输出到指定文件-c, --clipboard: 复制结果到剪切板(支持SSH环境)--clipboard-info: 显示剪切板环境信息--clipboard-method: 指定剪切板复制方法 (auto/osc52/pyperclip)-h, --help: 显示帮助信息
剪切板功能详解
本地环境
# 直接复制到系统剪切板
dir2prompt . -c
SSH环境
# 自动检测SSH环境,使用OSC 52转义序列
dir2prompt . -c
# 查看剪切板环境信息
dir2prompt . --clipboard-info
# 强制使用OSC 52方法(适用于SSH)
dir2prompt . -c --clipboard-method osc52
# 强制使用pyperclip方法(适用于本地)
dir2prompt . -c --clipboard-method pyperclip
支持的终端
OSC 52转义序列支持以下终端:
- iTerm2, Terminal.app (macOS)
- Windows Terminal, ConEmu (Windows)
- Alacritty, kitty, wezterm (跨平台)
- tmux, screen (终端复用器)
- VS Code集成终端
- 大多数现代终端模拟器
示例输出
project/
├── src/
│ ├── __init__.py
│ └── main.py
├── tests/
│ └── test_main.py
├── pyproject.toml
├── README.md
└── LICENSE
开发
如果你想参与开发或自定义功能:
# 克隆仓库
git clone https://github.com/Jeffjeno/dir2prompt.git
cd dir2prompt
# 安装开发依赖
pip install -e .
# 运行工具
dir2prompt .
许可证
MIT License
贡献
欢迎提交 Issue 和 Pull Request!
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
dir2prompts-0.2.0.tar.gz
(10.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dir2prompts-0.2.0.tar.gz.
File metadata
- Download URL: dir2prompts-0.2.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
65f31c77ecf47eeaf5844385b380620feda7afed5244edffc657bc6c3aec8341
|
|
| MD5 |
b461ee369a3cbabe23bd6c0a22605c57
|
|
| BLAKE2b-256 |
cf442afae31389a7ce20173a181908dda061546918df2abe888f668ec68ee851
|
File details
Details for the file dir2prompts-0.2.0-py3-none-any.whl.
File metadata
- Download URL: dir2prompts-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98b31d54f298e92f45e13007bff6bbbee19a4fa22c8f1ffc836edcda8294345d
|
|
| MD5 |
5fa130d70cb24bc604f6f73e03850170
|
|
| BLAKE2b-256 |
4952d02d4b18f2ed22b55d0f5fddadc94c0b9b5469c16fd4a70075bfce95115d
|