Skip to main content

一个将目录结构和文件内容复制到剪切板的工具

Project description

DirCat

PyPI version License: MIT

一个简单的命令行工具,可以将整个目录的结构和文件内容递归地复制到剪切板或输出到文件,方便与 AI 进行代码分析和调试。

🚀 安装

通过 pip 安装:

pip install dircat

✨ 特性

  • 结构清晰: 开头生成一个完整的目录树,结构一目了然
  • 多编码支持: 自动尝试常见编码 (UTF-8、GBK、Shift_JIS 等),也可通过 --encoding--fallback-encodings 自定义
  • 智能输出: 默认复制到剪切板,但在无剪切板环境会自动保存到文件
  • 文件输出: 使用 -o 选项可将所有内容直接输出到指定文件
  • 自动忽略: 默认跳过 .git, node_modules, __pycache__ 等常见的元数据和依赖文件夹,无需手动排除
  • 可配置忽略: 使用 -n/--exclude 永久写入 .dircatignore,或 -i/--ignore-temp 临时忽略特定文件/文件夹

📖 使用方法

基本用法

在您想要复制的项目根目录下,直接运行:

dircat

默认复制到剪切板。在无 GUI 环境下,将自动保存为 dircat_YYYYMMDD_HHMMSS.txt

输出到文件

使用 -o--output 选项指定输出文件:

dircat -o project_snapshot.txt

指定目录

您也可以指定一个特定的目录路径:

dircat /path/to/your/project

排除文件或文件夹

使用 -n--exclude 选项,永久添加忽略规则到 .dircatignore 文件中,支持通配符:

# 排除 build 文件夹和所有 .log 文件
dircat -n "build/" "*.log"

临时忽略文件或文件夹

使用 -i--ignore-temp 选项,可以临时忽略某些文件或文件夹,而不会将其添加到 .dircatignore 文件中。

# 本次运行忽略 build 文件夹和所有 .log 文件
dircat -i "build/" "*.log"

处理非 UTF-8 编码文件

使用 --encoding 指定首选编码,--fallback-encodings 指定额外尝试的编码列表。

# 优先使用 UTF-8,失败后尝试 GBK
dircat --encoding utf-8 --fallback-encodings gbk

默认会自动尝试常见的东亚编码 (GB18030、GBK、Big5、Shift_JIS、Latin-1)。

调整项目数量限制

默认情况下,如果一个文件夹下的文件和子文件夹总数超过 20,该文件夹将被跳过。您可以使用 --max-items 选项来修改这个限制:

dircat --max-items 30

📄 许可证

本项目根据 MIT 许可证授权。详情请参阅 LICENSE 文件。

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

dircat-0.2.1.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dircat-0.2.1-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file dircat-0.2.1.tar.gz.

File metadata

  • Download URL: dircat-0.2.1.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for dircat-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fffb82d7878a96aaa0527f4f38897b374d3c41f1912e678eda3955aafdfef16e
MD5 1b85c7f46414af55892d9c0248af6069
BLAKE2b-256 f4e6acbb42aeedbc3d0615de83a32100b2be55d951c8a6881f8d7b152517bff2

See more details on using hashes here.

File details

Details for the file dircat-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: dircat-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for dircat-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bac098ac3553c89cb720ffaea585d3269393f7206f66431ace2c42ef70b98f79
MD5 d8a382b8046a3b5c8ded14cc8628eef7
BLAKE2b-256 402ab89006d00008db308dccc1dab817147cc9ab3c8fd15f618dce1e8607ab7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page