Skip to content

iloveitaly/richclip

Repository files navigation

Inspect and Manipulate macOS Clipboard UTIs

richclip is a native macOS command-line tool that gives you granular control over your clipboard data. While standard tools like pbcopy and pbpaste only handle plain text, richclip allows you to inspect, read, and write any Uniform Type Identifier (UTI) format, such as public.html, public.png, or com.adobe.pdf.

This is particularly useful for enabling LLMs to inspect the full context of your clipboard, allowing them to see exactly how data is structured in various formats.

I built this because I often needed to debug what exactly was on my pasteboard when building web integrations or Raycast extensions. It's written in Swift with zero external runtime dependencies, utilizing the native NSPasteboard API.

Installation

You can install richclip using mise:

mise use -g github:iloveitaly/richclip

Alternatively, you can download the universal binary from the latest release and place it in your $PATH.

Usage

The tool is designed to be smart. It detects if you are piping data in or out to determine whether to copy or paste.

Basic Commands

# List all available UTIs on the clipboard with their contents in JSON
richclip list --json

# Copy plain text (implicit copy because of stdin)
echo "hello world" | richclip

# Paste plain text (implicit paste)
richclip

# Copy specific HTML content
echo "<b>Bold</b>" | richclip --type public.html

# Paste specific HTML content
richclip --type public.html

Advanced Binary Handling (Base64)

When dealing with complex raw binary blobs (e.g., specific internal data structures or Chromium pickled data), passing raw bytes via standard input/output in the shell can corrupt the data (due to null bytes or UTF-16 mismatches). richclip provides a --base64 flag to safely ingest and export binary data.

# Safely copy binary data to a custom UTI from a base64 string
echo "aGVsbG8=" | richclip copy --type com.example.binary --base64

# Export that specific UTI back to base64
richclip paste --type com.example.binary --base64

Advanced Inspection

Use the list subcommand to see exactly what's on your clipboard:

# Just list the UTIs
richclip list

# Get a full JSON breakdown of types and values (base64 for binary)
richclip list --json

Features

  • Universal Binary: Runs natively on both Intel and Apple Silicon Macs.
  • Implicit Actions: Automatically switches between copy and paste based on stdin presence. Only auto-copies if there is actual data piped in, preventing accidental clipboard clearing.
  • JSON Output: Inspect complex clipboard states including binary data encoded as Base64.
  • Smart Default Paste: Automatically picks the "richest" available UTI (the first representation provided by the source app).
  • Zero Dependencies: A single standalone Swift binary that uses native macOS APIs.

About

Inspect and manipulate macOS clipboard UTIs with granular control.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors