Skip to main content

Cross-platform CLI tool to merge text files and copy to clipboard for LLM context

Project description

pcopy - Project Copy Tool

GitHub release License

A cross-platform command-line tool that reads all text-based files in a specified folder, merges them into a single file called PROMPT.txt, and copies its entire content to the clipboard.

Perfect for preparing code context for AI assistants like ChatGPT and Claude!

📥 Quick Install

Option 1: Standalone Executable (Windows - Recommended)

No Python required!

  1. Download the latest release: pcopy-windows-x64.zip
  2. Extract and run: pcopy.exe tree
  3. Done! ✅

Option 2: Python Script (All Platforms)

Installation

  1. Install Python dependencies:
pip install -r requirements.txt
  1. (Optional) Add to PATH for global access:

Windows

# Add the script directory to PATH (replace with your actual path)
$env:Path += ";X:\Pcopy"
[Environment]::SetEnvironmentVariable("Path", $env:Path, [System.EnvironmentVariableTarget]::User)

Linux/WSL/Mac

# Create a symbolic link
sudo ln -s /path/to/pcopy/pcopy.py /usr/local/bin/pcopy
chmod +x /path/to/pcopy/pcopy.py

# Or add to .bashrc/.zshrc
echo 'alias pcopy="python3 /path/to/pcopy/pcopy.py"' >> ~/.bashrc

Usage

pcopy [tree] [path]

Arguments

  • path - (Optional) Path to the target directory. If omitted, uses the current working directory.
  • tree - (Optional keyword) If included, generates and prepends a file tree structure in the output.

Examples

# Use current directory, no file tree
pcopy

# Use specific directory
pcopy /home/user/project

# Add file tree for current directory
pcopy tree

# Add file tree for given path
pcopy tree "C:\Projects\App"

# On Windows with Python
python pcopy.py tree .

Features

📁 File Tree Generation

When the tree argument is used, pcopy generates an ASCII tree structure showing the hierarchy of all included files.

📄 Text File Detection

Automatically identifies text files based on:

  • Extension whitelist (.py, .js, .md, .json, etc.)
  • Binary content detection
  • File size limits (5 MB max)

🚫 .pcopyignore Support

Create a .pcopyignore file in your project root using .gitignore syntax:

# Ignore build artifacts
build/
dist/
*.log

# Ignore secrets
.env
secrets.json

# Keep configs even if in ignored dirs
!config.yaml

📋 Clipboard Integration

Automatically copies the merged content to your system clipboard (requires pyperclip).

🔍 Smart Filtering

Automatically ignores:

  • Binary files (.exe, .dll, .zip, .jpg, etc.)
  • Hidden files and folders
  • Common directories (.git, node_modules, __pycache__, etc.)
  • Files larger than 5 MB

Output Format

The generated PROMPT.txt includes:

==================================================================
📁 FILE TREE
==================================================================

project/
├── main.py
├── config.yaml
└── utils/
    ├── helper.py
    └── logger.py

==================================================================
📄 FILE CONTENTS
==================================================================

Filename: main.py
Content:
{
print("Hello world!")
}

------------------------------------------------------------------

Dependencies

  • pyperclip - Cross-platform clipboard support
  • pathspec - .gitignore-style pattern matching

Use Cases

1. Prepare Context for AI Assistants

cd my-project
pcopy tree
# Paste clipboard into ChatGPT/Claude with your question!

2. Code Reviews

pcopy tree feature-branch/
# Share PROMPT.txt with reviewers

3. Project Documentation

pcopy tree
# Quick overview of entire codebase

4. Project Snapshots

# Generate complete code listing
pcopy tree > project-snapshot.txt

🚀 Building Standalone Executable

Want to create your own standalone executable?

# Install PyInstaller
pip install pyinstaller

# Build executable
python -m PyInstaller --onefile --console --name pcopy pcopy.py

# Output: dist/pcopy.exe (Windows) or dist/pcopy (Linux/Mac)

See CONTRIBUTING.md for more details.

🤝 Contributing

Contributions are welcome! Please feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests
  • Improve documentation

See CONTRIBUTING.md for guidelines.

📝 Changelog

See Releases for version history.

🐛 Troubleshooting

"No text files found"

  • Check your .pcopyignore patterns
  • Verify you're in the correct directory

Clipboard not working on Linux

sudo apt-get install xclip

Permission errors

  • Run with appropriate permissions
  • Check file/folder access rights

⭐ Star this project

If you find pcopy useful, please give it a star on GitHub!

📄 License

MIT License - See LICENSE file for details.

🙏 Acknowledgments

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

pcopy_tool-1.0.0.tar.gz (19.2 kB view details)

Uploaded Source

Built Distribution

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

pcopy_tool-1.0.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pcopy_tool-1.0.0.tar.gz.

File metadata

  • Download URL: pcopy_tool-1.0.0.tar.gz
  • Upload date:
  • Size: 19.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pcopy_tool-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6572b1a197d3332b6b99b456a837bd39478caa71a97076920c4687a668fbda96
MD5 5b4aea864513f7a328af8587a9e67e90
BLAKE2b-256 6f53f5b6af65df21079b2309bbbb032700810aabd507823cd7a9126bd5850df5

See more details on using hashes here.

File details

Details for the file pcopy_tool-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pcopy_tool-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pcopy_tool-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b18b4d042fce02c5152c81bf07b0b0b7341cb9e54856f41f509fb188cbe430f6
MD5 63cd2414981cd4388f9c8cd7d15be3c3
BLAKE2b-256 372de1571c7f0bf3c18b8d3d04f80e263391c9db7a6184a4e41817a0453152a3

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