Your clipboard history, from Terminal
You copied a link, an error, or a screenshot an hour ago, and now your coding agent needs it. Instead of digging it up and pasting it in, tell the agent to find it.
How it works: On Hand 1.3.0 and later include the onhand command. It searches the history On Hand keeps on your Mac, prints a clip’s text (including the text in screenshots), copies clips back, and pauses capture. Claude Code, Codex, or any script can run it.
Try it
onhand search invoice
onhand get 3f2a91c0
onhand copy 3f2a91c0
onhand pin 3f2a91c0 --board SnippetsThat finds clips mentioning “invoice,” prints the full text of one, copies it back, and pins it to a board. IDs come from onhand search, and any unique start of one works, like a short Git hash. Add --json to search, get, boards, or status for output a script can parse.
Every command
| Command | What it does |
|---|---|
onhand search [words] | Newest clips containing all the words, one line each. Leave out the words for recent clips. |
onhand get ID | A clip’s full text. For an image, the text On Hand found in it; add --image out.png to save the image. |
onhand copy ID | Put a clip back on the clipboard. |
onhand pin ID --board NAME | Pin a clip so it never expires, optionally to a board. unpin undoes it. |
onhand boards | Your boards and how many clips each holds. |
onhand delete ID | Delete a clip from history. |
onhand forget-last | Clear the clipboard and delete what On Hand saved from it. |
onhand pause / resume | Stop saving copies, then start again. |
onhand status | Whether On Hand is saving copies, and how many clips it holds. |
search takes --kind text|link|image, --pinned, --sent (messages you sent, when Sent messages is on), --board NAME, and --limit N (10 by default, at most 50). Run onhand help for the full list.
Tell your agent about it
Add this line to your CLAUDE.md, AGENTS.md, or your agent’s instructions, so it reaches for your clipboard history when you mention something you copied:
On Hand keeps my clipboard history. When I mention something I copied earlier, find it with `onhand search <words>` and read it with `onhand get <id>`. Ask before deleting anything.Then ask things like:
- “Use the error I copied a few minutes ago and fix it.”
- “What was the order number in the screenshot I copied this morning?”
- “Pin the API docs link I copied to my Snippets board.”
- “Pause On Hand while you set up these credentials, then resume it.”
Install the command
If you installed On Hand with Homebrew, onhand is already on your PATH:
brew install --cask coreyhaines31/tap/onhandIf you downloaded the app instead, link the command once. It asks for your Mac password:
sudo mkdir -p /usr/local/bin
sudo ln -sf "/Applications/On Hand.app/Contents/MacOS/onhand" /usr/local/bin/onhandNew to On Hand? Start with the installation guide.
What your agent can see
onhanditself sends nothing anywhere. But whatever an agent reads with it goes to that agent’s AI provider, like any file it opens.searchshows only a one-line preview of each clip, at most 50 at a time. The full text comes fromget, one clip at a time.- Card numbers, Social Security numbers, and secret keys are never saved, so there’s nothing to find. Pause capture before copying anything else private.
Read the privacy policy for details.
Questions
Does On Hand have to be running?
No. The command reads and changes the same history file the app uses, so it works either way, and a running app shows the changes right away. On Hand has to be running to save new copies.
Which agents does it work with?
Any agent that can run Terminal commands, including Claude Code, Codex, Cursor, and Gemini CLI. There’s nothing to set up beyond the line in your instructions file.
Can I use it in my own scripts?
Yes. Use --json for structured output. Errors go to stderr, and the command exits with 1 when something fails and 2 for a typo in the command. The source is on GitHub.