A smarter macOS clipboard copy utility. cpcp is a drop in replacement for pbcopy that understands what you're trying to do.
⭐ Help get
cpcpinto Homebrew Core! If you find this tool useful, please leave a star ⭐. We need 75 stars to submit this utility to the official Homebrew repository so everyone can install it without tapping.
Native macOS pbcopy is good for basic scripting, but it has terrible developer UX:
- It copies trailing newlines from pipes (
echo "password" | pbcopy). - It copies invisible ANSI color codes from terminal logs, pasting gibberish into your editor.
- It doesn't understand non text files (like images, PDFs, etc).
- It offers zero feedback to tell you if the copy was successful (kinda not imp, but still).
cpcp fixes all of this.
✨ Clean Pastes by Default: Automatically strips trailing whitespaces and newlines from pipes. No more accidental form submissions when pasting tokens or passwords.
🎨 ANSI Stripping: Pipes from grep --color=always or logs are stripped of invisible color codes so they paste perfectly.
🧠 Smart File Detection: cpcp image.png copies the actual image to your clipboard so you can paste it directly into Slack, Figma, or Chrome.
👁️ Human Feedback: Prints a subtle success message (✔ Copied 42 characters) to the terminal (but stays silent inside bash scripts).
Currently available via a custom Homebrew tap. (Note: Homebrew requires you to temporarily trust third-party taps, Give a ⭐ to submit this utility to the official Homebrew repository).
brew tap vansh-j/cpcp
brew trust vansh-j/cpcp
brew install cpcp
Copy text directly:
cpcp "Hello world"
# ✔ Copied 11 characters
Pipe output (strips newlines & ANSI by default):
echo "password123" | cpcp
# ✔ Copied 11 characters from pipe (Trailing newline removed!)
Copy file contents (Text):
cpcp notes.txt
# ✔ Copied text contents of notes.txt
Copy file assets (Images, PDFs, etc.):
cpcp screenshot.png
# ✔ Copied file asset: screenshot.png
# Now hit Cmd+V in Slack, Figma, Browser, or Finder!
- **
-r,--raw**: Keep raw formatting. Bypasses the auto-cleaner to keep trailing newlines and ANSI color codes intact. - **
-t,--text-only**: Force input to be treated as literal text. Useful if you want to copy a string that happens to match a local file name (e.g.,cpcp -t "image.png"copies the word, not the file).
Pull requests are welcome!
- Fork it
- Create your feature branch (
git checkout -b feature/MyFeature) - Commit your changes (
git commit -m 'Add some MyFeature') - Push to the branch (
git push origin feature/MyFeature) - Open a Pull Request
MIT License.