Skip to main content

Ditch the copy-paste madness - browse, select, and format code for LLMs, keyboard-only.

Project description

pycmdc

Python Version PyPI version CI pre-commit.ci status License

Tired of Cmd+C'ing your way though files to feed your LLMs code context? Use cmdc instead to browse, grab, and format your code with style. Stop the manual copy-paste madness.

Features

  • Flexible Output: Copies to clipboard by default, supports console, and file output
  • Directory Browser: Visual tree structure for easy directory navigation
  • File Search: Fast file search and selection with fuzzy matching
  • LLM-Ready Format: Structured output with XML-style tags
  • Token Counting: Built-in token counter for LLM context awareness
  • Smart Ignore Rules: Automatic parsing of project's .gitignore files
  • Customizable: Configurable ignore patterns and file filters

Installation

Install using pip:

pip install pycmdc

Quick Start

  1. Navigate to your project directory:
cd your-project
  1. Run cmdc:
cmdc

This will open an interactive file browser where you can:

  • Navigate using arrow keys (↑/↓)
  • Toggle selection using arrow keys (←/→)
  • Search files by typing
  • Select all files using Ctrl+A
  • Toggle all selections using Ctrl+D
  • Confirm selection with Enter
  • Selected files will be structured and copied to your clipboard

Usage

Basic Commands

# Browse current directory
cmdc

# Browse specific directory
cmdc /path/to/directory

# Configure cmdc
cmdc --config

# Show help
cmdc --help

Advanced Options

# Filter by file extensions
cmdc --filters .py .js .ts

# Ignore specific patterns (combines with .gitignore rules)
cmdc --ignore "node_modules" "*.pyc"

# Disable .gitignore parsing
cmdc --no-gitignore

# Recursive directory traversal
cmdc --recursive

# Set maximum directory depth
cmdc --depth 2

# Save output to file
cmdc --output output.txt

# Non-interactive mode (select all matching files)
cmdc --non-interactive

Configuration

Run the configuration wizard:

cmdc --config

Show current configuration:

cmdc --config-show

List ignore patterns:

cmdc --list-ignore

Add new ignore patterns:

cmdc --add-ignore "*.log" "temp/*"

Output Format

cmdc generates structured output in an XML-like format:

<summary>
<selected_files>
file1.py
file2.js
</selected_files>
<directory_structure>
your-project/
├── file1.py
├── file2.js
└── src/
    └── other.py
</directory_structure>
</summary>

<open_file>
file1.py
<contents>
# Content of file1.py
</contents>
</open_file>

<open_file>
file2.js
<contents>
// Content of file2.js
</contents>
</open_file>

Configuration File

The configuration file is stored in:

  • Linux/macOS: ~/.config/cmdc/config.toml
  • Windows: %APPDATA%\cmdc\config.toml

Example configuration:

[cmdc]
recursive = false
depth = 3
copy_to_clipboard = true
print_to_console = false
use_gitignore = true
ignore_patterns = [ ".git", "node_modules", "__pycache__", "*.pyc", "venv", ".venv", "env", ".env", ".idea", ".vscode", ".pytest_cache", ".ruff_cache", ".mypy_cache", ".cache", ".DS_Store"]
filters = [".py", ".md"]
tiktoken_model = "o200k_base"

Environment Variables

You can override configuration using environment variables:

  • CMDC_FILTERS: Comma-separated list of file extensions
  • CMDC_IGNORE: Comma-separated list of ignore patterns
  • CMDC_RECURSIVE: Set to "true" for recursive mode
  • CMDC_COPY_CLIPBOARD: Set to "true" to enable clipboard copy
  • CMDC_USE_GITIGNORE: Set to "true" to use .gitignore patterns

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

pycmdc-1.3.0.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

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

pycmdc-1.3.0-py3-none-any.whl (19.3 kB view details)

Uploaded Python 3

File details

Details for the file pycmdc-1.3.0.tar.gz.

File metadata

  • Download URL: pycmdc-1.3.0.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycmdc-1.3.0.tar.gz
Algorithm Hash digest
SHA256 5386bda94397db96623b12842adb504202cf91b9c362e890b860136a4f6d03f5
MD5 cf623b57517f2ce7cbb66e254f43bf3d
BLAKE2b-256 80a98dc19344e4398c5d01ec0017f02f029c76ac826a51c7bab2456fe868d8bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycmdc-1.3.0.tar.gz:

Publisher: release.yml on 0xmrwn/pycmdc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pycmdc-1.3.0-py3-none-any.whl.

File metadata

  • Download URL: pycmdc-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 19.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pycmdc-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b20f60a59bee523ff48bd3bd0e9038d7154d02a098ca3ada688615ba7b99cba4
MD5 df6e1b364b66b4de2fa0b7d3c2b2e052
BLAKE2b-256 ed6301d3258ade31a95275f7f9d1a06374f7fb16f6799b09829ca285706825ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for pycmdc-1.3.0-py3-none-any.whl:

Publisher: release.yml on 0xmrwn/pycmdc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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