| name | osascript-clipboard |
| description | Read and write the macOS clipboard with full type support. Use when reading clipboard text, HTML, RTF, images, or file paths (Finder copy); writing rich content; detecting clipboard changes via changeCount; or intercepting content between copy and paste. |
osascript-clipboard
NSPasteboard via JXA — handles all clipboard types simultaneously.
theClipboard() in JXA standard additions is plain text only. NSPasteboard is the full API.
Clipboard Types
| UTI | Content |
|---|
public.utf8-plain-text | Plain text |
public.html | HTML with styling (web copy) |
public.rtf | Rich Text Format |
public.tiff / public.png | Image data |
NSFilenamesPboardType | File paths (Finder copy) |
public.url | URL string |
Scripts
Read all clipboard types — text, HTML, file paths, image presence:
uv run scripts/clipboard-read.py
Write plain text or text + HTML simultaneously to clipboard:
uv run scripts/clipboard-write.py "plain text content"
uv run scripts/clipboard-write.py "plain text" --html "<b>plain text</b>"
Poll changeCount and print new clipboard content whenever it changes:
uv run scripts/clipboard-watch.py
uv run scripts/clipboard-watch.py --interval 0.5
Reference
Key Pattern: Always clear before writing
pb.clearContents;
pb.setStringForType($("my text"), $("public.utf8-plain-text"));
Change detection without reading content:
var before = pb.changeCount();
if (pb.changeCount() !== before) {
}