Use macOS's built-in pbcopy/pbpaste to operate the clipboard.
Use Cases
- The user says "read the contents of my clipboard" or "help me copy this passage"
- Data needs to be passed via the clipboard during a task flow
- The content the user just copied needs to be obtained for processing
Command Reference
Read the clipboard
pbpaste
Write to the clipboard
echo "要复制的内容" | pbcopy
Copy from a file to the clipboard
pbcopy < "/path/to/file.txt"
Save the clipboard contents to a file
pbpaste > "/path/to/output.txt"
Append the clipboard contents to a file
pbpaste >> "/path/to/output.txt"
Output Specifications
- After reading the clipboard, display the contents (for long text, truncate and show the first 500 characters)
- After writing to the clipboard, confirm "Copied to clipboard"
- When processing clipboard contents, display the contents first, then confirm the operation