A versatile command-line utility for copying file contents, directory contents, or STDIN input to the system clipboard. Supports both text and image files, with special features for Discord formatting and debug output.
- Copy text from files to clipboard
- Copy text from STDIN to clipboard
- Copy contents of all files in a directory
- Copy images to clipboard
- Include headers with filenames
- Format output for Discord
- Verbose output option
- Debug mode
- Python 3.x
- pyperclip
- PIL (for image support)
- xclip or xsel (Linux only)
- Install package with pipx:
pipx install .
pipx uninstall copybuffer)
- For Linux systems, install clipboard handlers:
sudo apt-get install xclip
# or
sudo apt-get install xsel
# Copy file contents
cb filename.txt
# Copy from STDIN
echo "hello" | cb
# Copy directory contents
cb -d directory/
# Copy with Discord formatting
cb -a filename.txt
# Copy with headers
cb -i filename.txt
file
: File to copy (optional - reads from STDIN if not provided)-i, --include-header
: Include filename as header in copied text-d, --directory
: Copy contents of all files in directory-v, --verbose
: Display the copied contents-a, --attachment
: Format output as Discord attachment--debug
: Enable debug mode--version
: Display application version
Supports copying image files directly to clipboard:
- PNG
- JPG/JPEG
- BMP
- GIF (first frame)
cb image.png
Copy contents of all text files in a directory:
cb -d /path/to/directory
- Automatically skips image files
- Optionally includes headers with -i flag
- Can format as Discord attachments with -a flag
Enable detailed output for troubleshooting:
cb --debug filename.txt
# Display version information
cb --version
# Output: cb.py version v1.5
The script provides clear error messages for common issues:
- Missing dependencies
- File not found
- Permission errors
- Invalid file types
- Directory access errors
cb -i document.txt
# Output includes: === document.txt ===
cb -a code.py
# Output format: [Attached file: code.py\nContent:\n```\n...\n```\n]
cb -d -v -i /path/to/docs
# Shows all processed files and copied content
If you encounter issues:
- Check dependencies with --debug flag
- Verify clipboard system access
- Check file permissions
- Ensure proper Python version
This project is open source and available under the MIT License.
For issues or suggestions: [email protected]