dir2prompts


Namedir2prompts JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/Jeffjeno/dir2prompt
Summary一个生成目录树结构的命令行工具
upload_time2025-08-20 08:20:37
maintainerNone
docs_urlNone
authorWangZhiZhou
requires_python>=3.7
licenseMIT License Copyright (c) 2025 WangZhiZhou Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords directory tree file-structure command-line
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # dir2prompt

一个简单易用的命令行工具,用于生成目录树结构。

## 功能特点

- 生成清晰的目录树结构
- 支持排除指定目录或文件
- 支持仅包含指定目录或文件
- 跨平台支持(Windows、macOS、Linux)
- **🆕 智能剪切板支持(默认启用)**
  - 默认同时在终端显示并复制到剪切板
  - 本地环境:使用系统剪切板
  - SSH环境:通过OSC 52转义序列支持远程剪切板  
  - 自动检测环境并选择最佳复制方法
- 简洁的命令行界面

## 安装

使用 pip 安装:

```bash
pip install dir2prompt
```

## 使用方法

### 基本用法

```bash
# 显示当前目录的树结构(默认同时复制到剪切板)
dir2prompt .

# 显示指定目录的树结构(默认同时复制到剪切板)
dir2prompt /path/to/your/project
```

### 高级用法

```bash
# 排除特定目录
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 . --no-clipboard
```

### 命令行选项

- `path`: 要扫描的目录路径
- `--ex, --exclude`: 排除的路径(可多次使用)
- `--in, --include`: 包含的路径(可多次使用)
- `-o, --output`: 输出到指定文件
- `--no-clipboard`: 禁用剪切板功能,仅在终端显示
- `--clipboard-info`: 显示剪切板环境信息
- `--clipboard-method`: 指定剪切板复制方法 (`auto`/`osc52`/`pyperclip`)
- `-h, --help`: 显示帮助信息

### 剪切板功能详解

#### 默认行为
```bash
# 默认同时显示在终端并复制到剪切板
dir2prompt .

# 仅在终端显示,不复制到剪切板
dir2prompt . --no-clipboard
```

#### 环境自适应
```bash
# 本地环境:自动使用系统剪切板
# SSH环境:自动使用OSC 52转义序列
dir2prompt .

# 查看剪切板环境信息
dir2prompt . --clipboard-info

# 强制使用OSC 52方法(适用于SSH)
dir2prompt . --clipboard-method osc52

# 强制使用pyperclip方法(适用于本地)
dir2prompt . --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
```

## 开发

如果你想参与开发或自定义功能:

```bash
# 克隆仓库
git clone https://github.com/Jeffjeno/dir2prompt.git
cd dir2prompt

# 安装开发依赖
pip install -e .

# 运行工具
dir2prompt .
```

## 许可证

MIT License

## 贡献

欢迎提交 Issue 和 Pull Request!

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Jeffjeno/dir2prompt",
    "name": "dir2prompts",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "directory, tree, file-structure, command-line",
    "author": "WangZhiZhou",
    "author_email": "WangZhiZhou <jenojeff66@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/a0/c7/9123e58defe802e5102750e7a06e57633f42e602f30c4541c1d04c15aed7/dir2prompts-0.2.2.tar.gz",
    "platform": null,
    "description": "# dir2prompt\n\n\u4e00\u4e2a\u7b80\u5355\u6613\u7528\u7684\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u7528\u4e8e\u751f\u6210\u76ee\u5f55\u6811\u7ed3\u6784\u3002\n\n## \u529f\u80fd\u7279\u70b9\n\n- \u751f\u6210\u6e05\u6670\u7684\u76ee\u5f55\u6811\u7ed3\u6784\n- \u652f\u6301\u6392\u9664\u6307\u5b9a\u76ee\u5f55\u6216\u6587\u4ef6\n- \u652f\u6301\u4ec5\u5305\u542b\u6307\u5b9a\u76ee\u5f55\u6216\u6587\u4ef6\n- \u8de8\u5e73\u53f0\u652f\u6301\uff08Windows\u3001macOS\u3001Linux\uff09\n- **\ud83c\udd95 \u667a\u80fd\u526a\u5207\u677f\u652f\u6301\uff08\u9ed8\u8ba4\u542f\u7528\uff09**\n  - \u9ed8\u8ba4\u540c\u65f6\u5728\u7ec8\u7aef\u663e\u793a\u5e76\u590d\u5236\u5230\u526a\u5207\u677f\n  - \u672c\u5730\u73af\u5883\uff1a\u4f7f\u7528\u7cfb\u7edf\u526a\u5207\u677f\n  - SSH\u73af\u5883\uff1a\u901a\u8fc7OSC 52\u8f6c\u4e49\u5e8f\u5217\u652f\u6301\u8fdc\u7a0b\u526a\u5207\u677f  \n  - \u81ea\u52a8\u68c0\u6d4b\u73af\u5883\u5e76\u9009\u62e9\u6700\u4f73\u590d\u5236\u65b9\u6cd5\n- \u7b80\u6d01\u7684\u547d\u4ee4\u884c\u754c\u9762\n\n## \u5b89\u88c5\n\n\u4f7f\u7528 pip \u5b89\u88c5\uff1a\n\n```bash\npip install dir2prompt\n```\n\n## \u4f7f\u7528\u65b9\u6cd5\n\n### \u57fa\u672c\u7528\u6cd5\n\n```bash\n# \u663e\u793a\u5f53\u524d\u76ee\u5f55\u7684\u6811\u7ed3\u6784\uff08\u9ed8\u8ba4\u540c\u65f6\u590d\u5236\u5230\u526a\u5207\u677f\uff09\ndir2prompt .\n\n# \u663e\u793a\u6307\u5b9a\u76ee\u5f55\u7684\u6811\u7ed3\u6784\uff08\u9ed8\u8ba4\u540c\u65f6\u590d\u5236\u5230\u526a\u5207\u677f\uff09\ndir2prompt /path/to/your/project\n```\n\n### \u9ad8\u7ea7\u7528\u6cd5\n\n```bash\n# \u6392\u9664\u7279\u5b9a\u76ee\u5f55\ndir2prompt . --ex node_modules --ex .git\n\n# \u4ec5\u5305\u542b\u7279\u5b9a\u76ee\u5f55\ndir2prompt /project --in src --in docs\n\n# \u7ec4\u5408\u4f7f\u7528\u6392\u9664\u548c\u5305\u542b\ndir2prompt /project --ex __pycache__ --in src --in tests\n\n# \u8f93\u51fa\u5230\u6587\u4ef6\uff08\u540c\u65f6\u590d\u5236\u5230\u526a\u5207\u677f\uff09\ndir2prompt . -o tree.txt\n\n# \u4ec5\u663e\u793a\u5728\u7ec8\u7aef\uff0c\u4e0d\u590d\u5236\u5230\u526a\u5207\u677f\ndir2prompt . --no-clipboard\n```\n\n### \u547d\u4ee4\u884c\u9009\u9879\n\n- `path`: \u8981\u626b\u63cf\u7684\u76ee\u5f55\u8def\u5f84\n- `--ex, --exclude`: \u6392\u9664\u7684\u8def\u5f84\uff08\u53ef\u591a\u6b21\u4f7f\u7528\uff09\n- `--in, --include`: \u5305\u542b\u7684\u8def\u5f84\uff08\u53ef\u591a\u6b21\u4f7f\u7528\uff09\n- `-o, --output`: \u8f93\u51fa\u5230\u6307\u5b9a\u6587\u4ef6\n- `--no-clipboard`: \u7981\u7528\u526a\u5207\u677f\u529f\u80fd\uff0c\u4ec5\u5728\u7ec8\u7aef\u663e\u793a\n- `--clipboard-info`: \u663e\u793a\u526a\u5207\u677f\u73af\u5883\u4fe1\u606f\n- `--clipboard-method`: \u6307\u5b9a\u526a\u5207\u677f\u590d\u5236\u65b9\u6cd5 (`auto`/`osc52`/`pyperclip`)\n- `-h, --help`: \u663e\u793a\u5e2e\u52a9\u4fe1\u606f\n\n### \u526a\u5207\u677f\u529f\u80fd\u8be6\u89e3\n\n#### \u9ed8\u8ba4\u884c\u4e3a\n```bash\n# \u9ed8\u8ba4\u540c\u65f6\u663e\u793a\u5728\u7ec8\u7aef\u5e76\u590d\u5236\u5230\u526a\u5207\u677f\ndir2prompt .\n\n# \u4ec5\u5728\u7ec8\u7aef\u663e\u793a\uff0c\u4e0d\u590d\u5236\u5230\u526a\u5207\u677f\ndir2prompt . --no-clipboard\n```\n\n#### \u73af\u5883\u81ea\u9002\u5e94\n```bash\n# \u672c\u5730\u73af\u5883\uff1a\u81ea\u52a8\u4f7f\u7528\u7cfb\u7edf\u526a\u5207\u677f\n# SSH\u73af\u5883\uff1a\u81ea\u52a8\u4f7f\u7528OSC 52\u8f6c\u4e49\u5e8f\u5217\ndir2prompt .\n\n# \u67e5\u770b\u526a\u5207\u677f\u73af\u5883\u4fe1\u606f\ndir2prompt . --clipboard-info\n\n# \u5f3a\u5236\u4f7f\u7528OSC 52\u65b9\u6cd5\uff08\u9002\u7528\u4e8eSSH\uff09\ndir2prompt . --clipboard-method osc52\n\n# \u5f3a\u5236\u4f7f\u7528pyperclip\u65b9\u6cd5\uff08\u9002\u7528\u4e8e\u672c\u5730\uff09\ndir2prompt . --clipboard-method pyperclip\n```\n\n#### \u652f\u6301\u7684\u7ec8\u7aef\nOSC 52\u8f6c\u4e49\u5e8f\u5217\u652f\u6301\u4ee5\u4e0b\u7ec8\u7aef\uff1a\n- iTerm2, Terminal.app (macOS)\n- Windows Terminal, ConEmu (Windows) \n- Alacritty, kitty, wezterm (\u8de8\u5e73\u53f0)\n- tmux, screen (\u7ec8\u7aef\u590d\u7528\u5668)\n- VS Code\u96c6\u6210\u7ec8\u7aef\n- \u5927\u591a\u6570\u73b0\u4ee3\u7ec8\u7aef\u6a21\u62df\u5668\n\n## \u793a\u4f8b\u8f93\u51fa\n\n```\nproject/\n\u251c\u2500\u2500 src/\n\u2502   \u251c\u2500\u2500 __init__.py\n\u2502   \u2514\u2500\u2500 main.py\n\u251c\u2500\u2500 tests/\n\u2502   \u2514\u2500\u2500 test_main.py\n\u251c\u2500\u2500 pyproject.toml\n\u251c\u2500\u2500 README.md\n\u2514\u2500\u2500 LICENSE\n```\n\n## \u5f00\u53d1\n\n\u5982\u679c\u4f60\u60f3\u53c2\u4e0e\u5f00\u53d1\u6216\u81ea\u5b9a\u4e49\u529f\u80fd\uff1a\n\n```bash\n# \u514b\u9686\u4ed3\u5e93\ngit clone https://github.com/Jeffjeno/dir2prompt.git\ncd dir2prompt\n\n# \u5b89\u88c5\u5f00\u53d1\u4f9d\u8d56\npip install -e .\n\n# \u8fd0\u884c\u5de5\u5177\ndir2prompt .\n```\n\n## \u8bb8\u53ef\u8bc1\n\nMIT License\n\n## \u8d21\u732e\n\n\u6b22\u8fce\u63d0\u4ea4 Issue \u548c Pull Request\uff01\n",
    "bugtrack_url": null,
    "license": "MIT License\n        \n        Copyright (c) 2025 WangZhiZhou\n        \n        Permission is hereby granted, free of charge, to any person obtaining a copy\n        of this software and associated documentation files (the \"Software\"), to deal\n        in the Software without restriction, including without limitation the rights\n        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n        copies of the Software, and to permit persons to whom the Software is\n        furnished to do so, subject to the following conditions:\n        \n        The above copyright notice and this permission notice shall be included in all\n        copies or substantial portions of the Software.\n        \n        THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n        SOFTWARE.",
    "summary": "\u4e00\u4e2a\u751f\u6210\u76ee\u5f55\u6811\u7ed3\u6784\u7684\u547d\u4ee4\u884c\u5de5\u5177",
    "version": "0.2.2",
    "project_urls": {
        "Bug Reports": "https://github.com/Jeffjeno/dir2prompt/issues",
        "Homepage": "https://github.com/Jeffjeno/dir2prompt",
        "Source": "https://github.com/Jeffjeno/dir2prompt"
    },
    "split_keywords": [
        "directory",
        " tree",
        " file-structure",
        " command-line"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "78551372f81c547324cb1d6f15a17d0fe0282435704797294d43943602463a7d",
                "md5": "93cdfb36c72e6dcef5e43760750cf295",
                "sha256": "08aca9828bafe96bdaeb416b85c585269a8573b5a3cd40d66da8b2859152b6b3"
            },
            "downloads": -1,
            "filename": "dir2prompts-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "93cdfb36c72e6dcef5e43760750cf295",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 10159,
            "upload_time": "2025-08-20T08:20:36",
            "upload_time_iso_8601": "2025-08-20T08:20:36.353077Z",
            "url": "https://files.pythonhosted.org/packages/78/55/1372f81c547324cb1d6f15a17d0fe0282435704797294d43943602463a7d/dir2prompts-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "a0c79123e58defe802e5102750e7a06e57633f42e602f30c4541c1d04c15aed7",
                "md5": "aea7065330beb11907808e622d7d2518",
                "sha256": "65ab46fab82422efc093877effe75a7c1413b0bc3327d3232055e191343d8334"
            },
            "downloads": -1,
            "filename": "dir2prompts-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "aea7065330beb11907808e622d7d2518",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10444,
            "upload_time": "2025-08-20T08:20:37",
            "upload_time_iso_8601": "2025-08-20T08:20:37.469509Z",
            "url": "https://files.pythonhosted.org/packages/a0/c7/9123e58defe802e5102750e7a06e57633f42e602f30c4541c1d04c15aed7/dir2prompts-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-20 08:20:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Jeffjeno",
    "github_project": "dir2prompt",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "dir2prompts"
}
        
Elapsed time: 0.60636s