Skip to main content
Write plain-text content to the macOS system clipboard (pasteboard), replacing any existing content.

Usage

agent-desktop clipboard-set <TEXT>

Parameters

TEXT
string
required
The plain-text content to write to the clipboard. Supports newlines, special characters, and Unicode.
agent-desktop clipboard-set "Hello, world!"
For multi-line text, use shell quoting:
agent-desktop clipboard-set "Line 1
Line 2
Line 3"

Response

ok
boolean
required
Always true if the operation succeeded

Examples

Set Simple Text

agent-desktop clipboard-set "Hello, world!"
{
  "version": "1.0",
  "ok": true,
  "command": "clipboard-set",
  "data": {
    "ok": true
  }
}

Set Multi-Line Text

agent-desktop clipboard-set "First line
Second line
Third line"
{
  "version": "1.0",
  "ok": true,
  "command": "clipboard-set",
  "data": {
    "ok": true
  }
}

Set from Variable

CONTENT="Some dynamic content"
agent-desktop clipboard-set "$CONTENT"

Set from File

agent-desktop clipboard-set "$(cat file.txt)"

Use Cases

Copy data to clipboard without user interaction:
# Copy computed result
RESULT=$(curl -s https://api.example.com/data | jq -r '.value')
agent-desktop clipboard-set "$RESULT"
Set clipboard content before pasting into an app:
agent-desktop clipboard-set "[email protected]"
agent-desktop focus-window --app Safari
agent-desktop click @e5  # click email field
agent-desktop press cmd+v
Transfer data via clipboard:
# Read from source
DATA=$(agent-desktop get @e3 value)

# Write to clipboard
agent-desktop clipboard-set "$DATA"

# Paste to destination
agent-desktop focus-window --app TextEdit
agent-desktop press cmd+v
Paste multiple values in sequence:
VALUES=("value1" "value2" "value3")

for val in "${VALUES[@]}"; do
  agent-desktop clipboard-set "$val"
  agent-desktop click @e5
  agent-desktop press cmd+v
  agent-desktop press tab
done
Copy templated content:
NAME="John Doe"
EMAIL="[email protected]"
TEMPLATE="Hello $NAME,\n\nYour email is: $EMAIL"

agent-desktop clipboard-set "$TEMPLATE"

Clipboard Behavior

  • Replaces existing content: Any previous clipboard content is overwritten
  • Plain text only: This command only sets plain text; images, files, and rich text are not supported
  • System-wide: The clipboard is shared across all applications
  • Persistent: Clipboard content remains until replaced or cleared
  • Newlines preserved: Multi-line text is preserved exactly as provided

Special Characters

The command handles special characters correctly:
# Unicode
agent-desktop clipboard-set "Hello δΈ–η•Œ 🌍"

# Quotes
agent-desktop clipboard-set 'Text with "quotes"'

# Backslashes
agent-desktop clipboard-set "Path: C:\\Users\\Name"

# Newlines
agent-desktop clipboard-set $'Line 1\nLine 2'  # bash $'...' syntax

Permissions

Setting the clipboard requires macOS accessibility permission. If permission is not granted, the command will return a PERM_DENIED error:
{
  "version": "1.0",
  "ok": false,
  "command": "clipboard-set",
  "error": {
    "code": "PERM_DENIED",
    "message": "Accessibility permission not granted",
    "suggestion": "Open System Settings > Privacy & Security > Accessibility and add your terminal app"
  }
}

Notes

  • The operation is synchronous and completes immediately
  • Maximum clipboard size is limited by macOS (typically several MB for text)
  • The clipboard content is available to all apps immediately after the command succeeds
  • Use clipboard-clear to explicitly empty the clipboard
  • clipboard-get - Read text from the clipboard
  • clipboard-clear - Clear the clipboard
  • press - Send keyboard shortcuts like cmd+v to paste
  • type - Type text directly into an element (alternative to clipboard+paste)

Build docs developers (and LLMs) love