A very simple, safe, and cross-platform command-line tool to copy text from files or stdin directly to your system clipboard.
copycmd is designed to behave like a real UNIX utility:
- Works with pipes (
|) - Handles encodings safely
- Avoids copying binary data by default
- Supports Linux (X11 & Wayland), macOS, and Windows
- 📋 Copy file contents to clipboard
- 🔗 Read from stdin (pipes)
- 🛡️ Binary detection to prevent accidental garbage copies
- ⚙️ Encoding fallback (
utf-8,latin-1, etc.) - 🐧 Linux-aware clipboard verification (X11 & Wayland)
- 🖥 Works on Windows, macOS, and Linux
- 🧩 Minimal dependencies (
pypercliponly)
copycmd/
├── copy_command.py # Main CLI tool
├── installer.py # Installer script
├── README.md
└── README_ES.md
- Python 3.6+
pyperclip
Depending on your environment:
-
X11:
sudo apt install xclip
-
Wayland:
sudo apt install wl-clipboard
Optional pip extras:
pip install 'pyperclip[xclip]'Clone the repository:
git clone https://github.com/URDev4ever/copycmd.git
cd copycmdInstall the command:
python installer.pyThe installer will:
- Copy
copy_command.pyto an appropriate directory - Create a
copywrapper command - Warn you if the directory is not in your
PATH
copy file.txtcat file.txt | copy
echo "hello world" | copy
ls -la | copycat *.txt | copycopy file.txt -v
cat file.txt | copy -vcopy suspicious.bin -fThis copies a preview, not the full binary file.
-
If stdin is present, it always takes priority over file arguments:
echo test | copy file.txt # copies 'test', ignores file.txt
-
On Linux Wayland, clipboard verification may be limited due to compositor restrictions.
-
Large files (>10MB) are rejected by default.
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Error |
| 130 | Cancelled (Ctrl+C) |
Run directly without installing (NOT recommended):
python copy_command.py file.txtPull requests are welcome if they improve the command by:
- Adding useful CLI flags or quality-of-life options
- Improving clipboard detection or compatibility across platforms
- Making the code simpler, safer, or more robust
Please report any bugs you encounter, thx ;) If you like this project, feel free to ⭐ the repository!
Made with <3 by URDev