A CLI tool to flatten directory contents to clipboard for LLM context.
Project description
Dir2Clip
A command-line tool that recursively scans a directory, formats text files into a single string, and copies them to the clipboard. Useful for quickly pasting code context into LLMs.
Features
- Smart Scanning: By default, scans only the current directory. Use
-rfor recursive scanning. - Filters binary files and common ignores (e.g.,
.git,venv,__pycache__). - Formats output with Markdown headers (
### FILE: path/to/file) and code blocks. - Truncates output (default: 100k chars) to prevent exceeding clipboard or context limits.
- Cross-platform clipboard support (Linux/macOS/Windows).
Installation
Install via pip:
pip install dir2clip
Note: Linux users may need xclip or xsel installed (sudo apt install xclip).
Usage
Run dir2clip in your terminal:
# Scan current directory (files only)
dir2clip
# Scan with recursion (include subdirectories)
dir2clip -r
# Scan specific path recursively
dir2clip ./src -r
# Set character limit (default: 100000)
dir2clip --max-len 50000
Output Format
The tool copies content in this format:
### FILE: src/main.py
import os ...
### FILE: README.md
Documentation
...
Configuration
To exclude additional directories, you can modify the IGNORE_DIRS set in the source code or file an issue to make it configurable via args.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 dir2clip-0.1.3.tar.gz.
File metadata
- Download URL: dir2clip-0.1.3.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
992714c798bd7a076d86f8d7d00abe3181cd24fd619d6ae3f0d3ea9966db0680
|
|
| MD5 |
9e44e520f6abdf19bae579de9812a648
|
|
| BLAKE2b-256 |
77e7ccc0cf725a8c45c86b46e83733d0048cadc92dcb76e3be8f1d10e6942fd2
|
File details
Details for the file dir2clip-0.1.3-py3-none-any.whl.
File metadata
- Download URL: dir2clip-0.1.3-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b993f5f73260012ab2e2572de087351bcfc9b6af30ebafe77d4a501d0cbde51
|
|
| MD5 |
3c1603431bbada09e4c57c7c381c5600
|
|
| BLAKE2b-256 |
8f2198a8e4d0928aa78fcde09c72367b83089ebde451258d61508aef25c00144
|