Settings

Theme

Show HN: Clippy – a better pbcopy for macOS that handles files properly

github.com

34 points by nberkman 5 months ago · 14 comments · 1 min read

Reader

I made clippy because pbcopy can't do something I needed every day: copy files to paste into GUI apps. When you pbcopy < image.png, you get raw bytes instead of a file that Slack or email can use.

Clippy fixes this:

- clippy report.pdf → ⌘V into any app uploads the file

- curl image.png | clippy → pipes become pasteable files

- clippy *.jpg → multiple files at once

- Text files still work like pbcopy

Technical: Direct Objective-C bindings via CGo. Copies file references (like Finder), not contents. Auto-cleans temp files. No AppleScript hacks.

Install: brew install neilberkman/clippy/clippy

feraldidactic 5 months ago

A certain large software concern might take issue with the name. Mac users of a certain age might just run…

nocsi 5 months ago

So technically the OS is supposed to be handling this, or at the least whatever app you're in is supposed to signal the MIME to the pasteboard. They even updated the APIs for it this year. I'm not complaining, just giving away loose headsup that they might rugpull you. Apple is particularly not a fan of oblique data transformations, especially since malware keeps going after the user's pasteboards.

Something worth implementing is multiple layers to the pasteboard content, so you're at least maintaining the original raw bytes. That and I always wanted a pasteboard that let you append contents to it. Just some ideas to consider

  • nberkmanOP 5 months ago

    Thanks. I just released a new version with UTI based MIME type detection as the primary method with a fallback to the existing content-based detection.

donatj 5 months ago

Neat, I was actually looking for something like this a few months ago to help automate part of a workflow.

Be kind of nice if this also worked as a library rather than having all the workings in internal where they can't be called.

Unrelated: Is yo.txt in the root just junk?

SamInTheShell 5 months ago

Probably worth knowing, there’s already a popular clipboard manager in the wild for MacOS called Clipy.

https://github.com/Clipy/Clipy

physPop 5 months ago

clippy is kind of taken (a very popular rust linter). Suggest considering a new name to differentiate yourself!

jdmg94 5 months ago

linux compat would've been nice

  • wut42 5 months ago

    already exists, xsel and xclip does that, iirc.

    • nberkmanOP 5 months ago

      clippy is a bit different from these - rather than requiring manual flags for MIME types, it automatically detects the content type. The idea is to make the CLI's copy/paste feel as intuitive as the GUI's.

      I might tackle Linux (and Windows) at some point, but contributions are definitely welcome!

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection