pbcopy
Skill2 starsChanged 8 months agoMITView on GitHub
Copy text, HTML, or images to the macOS clipboard using pbcopy and osascript. Use when the user asks to copy, share, or transfer content to the clipboard, or when generating output that the user will need to paste elsewhere (e.g., commands, code snippets, config blocks, URLs, tokens, images, rich text). Triggers on mentions of copy, clipboard, paste, pbcopy, or "copy to clipboard".
In this repository12 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- 1password-cliSkill
- awscliSkill
- gandi-cliSkill
- iterm2-automationSkill
- iterm2-profilesSkill
- iterm2-shell-setupSkill
- syncthingSkill
- synology-cliSkill
- tailscale-cliSkill
- textual-tuiSkill
- your-skill-nameSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 68
If you need the clipboard to contain native HTML type (not RTF), use osascript:
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Clipboard (pbcopy/pbpaste/osascript)
Automatically copy text, HTML, or images to the macOS clipboard so the user can paste it directly.
When to Use
- The user explicitly asks to copy something to the clipboard
- You generate a snippet (command, code, config, URL, token) that the user said they want to paste elsewhere
- The user asks to copy an image or rich text/HTML to the clipboard
- The user asks you to "put it in my clipboard" or "copy that for me"
Plain Text
# Copy text to clipboard
echo -n 'text to copy' | pbcopy
# Copy multi-line text to clipboard
cat <<'EOF' | pbcopy
line 1
line 2
EOF
# Copy file contents to clipboard
pbcopy < /path/to/file
# Copy command output to clipboard
some-command | pbcopy
# Read current clipboard contents
pbpasteHTML / Rich Text
pbcopy automatically detects RTF headers, so convert HTML to RTF with textutil then pipe to pbcopy. The clipboard will contain rich text pasteable into Mail, Notion, Google Docs, etc.
# Convert HTML to RTF and copy to clipboard (preferred)
echo '<h1>Title</h1><p>This is <b>bold</b></p>' | textutil -stdin -format html -convert rtf -stdout | pbcopy
# From an HTML file
textutil -convert rtf /path/to/page.html -stdout | pbcopy
# Copy raw RTF directly (pbcopy auto-detects RTF header)
cat <<'EOF' | pbcopy
{\rtf1\ansi\deff0{\fonttbl{\f0 Helvetica;}}\f0\fs24 Hello \b Bold\b0 World}
EOF
# Paste as RTF
pbpaste -Prefer rtfIf you need the clipboard to contain native HTML type (not RTF), use osascript:
cat <<'EOF' > /tmp/clip.html
<h1>Title</h1>
<ul><li>Item 1</li><li>Item 2</li></ul>
EOF
osascript <<'APPLESCRIPT'
use framework "AppKit"
set htmlContent to do shell script "cat /tmp/clip.html"
set pb to current application's NSPasteboard's generalPasteboard()
pb's clearContents()
pb's setString:htmlContent forType:(current application's NSPasteboardTypeHTML)
APPLESCRIPT
rm /tmp/clip.htmlImages
pbcopy only handles text/RTF/EPS — images require osascript with NSPasteboard.
# Copy image to clipboard (PNG, JPG, GIF, TIFF, BMP, WebP)
osascript <<APPLESCRIPT
use framework "AppKit"
set img to (current application's NSImage's alloc()'s initWithContentsOfFile:"/path/to/image.png")
set pb to current application's NSPasteboard's generalPasteboard()
pb's clearContents()
pb's writeObjects:{img}
APPLESCRIPTReading Clipboard
# Read plain text
pbpaste
# Read as RTF
pbpaste -Prefer rtf
# Check clipboard content types
osascript -e 'the clipboard as record'
# Save clipboard image to file
osascript <<'APPLESCRIPT'
use framework "AppKit"
set pb to current application's NSPasteboard's generalPasteboard()
set imgData to pb's dataForType:(current application's NSPasteboardTypePNG)
if imgData is not missing value then
imgData's writeToFile:"/tmp/clipboard.png" atomically:true
return "Saved to /tmp/clipboard.png"
else
return "No image on clipboard"
end if
APPLESCRIPTRules
- Use
echo -n(no trailing newline) for single-line values like URLs, tokens, and one-liners. - Use heredoc with
'EOF'(single-quoted delimiter) for multi-line content to prevent shell expansion. - Always confirm what was copied by telling the user — e.g., "Copied the API key to your clipboard."
- Never silently copy — always inform the user when you put something in their clipboard.
- Sensitive data — warn the user if clipboard content contains secrets, as clipboard contents can be read by other apps.
- Temp files — delete any temp files (
/tmp/clip.html, etc.) after copying to clipboard. - Choose the right method:
- Plain text →
echo | pbcopy - HTML/rich text →
textutil -convert rtf -stdout | pbcopy(preferred) orosascriptfor native HTML type - Images →
osascriptwithNSImage+NSPasteboard(pbcopy cannot handle images)
- Plain text →
- macOS only — these commands use macOS APIs. On Linux, suggest
xclip -selection clipboardorxsel --clipboardfor text (rich content requiresxclip -t text/htmlor similar).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

