From copyq-scripting
Read the current clipboard, the X11 PRIMARY selection, or any item from CopyQ history — by row, by MIME type, or filtered by regex. Use when the user wants to inspect what's on the clipboard, dump history to a file, or pipe clipboard contents into another tool.
npx claudepluginhub danielrosehill/claude-code-plugins --plugin copyq-scriptingThis skill uses the workspace's default tool permissions.
```bash
Mandates invoking relevant skills via tools before any response in coding sessions. Covers access, priorities, and adaptations for Claude Code, Copilot CLI, Gemini CLI.
Share bugs, ideas, or general feedback.
copyq clipboard # text/plain (default)
copyq clipboard text/html # HTML representation
copyq clipboard text/uri-list # file URIs (when files are copied)
copyq clipboard image/png > /tmp/clip.png # image data
List MIME types currently on the clipboard:
copyq eval -- 'print(clipboard("?"))'
copyq selection
Only meaningful on X11 sessions. On Wayland, PRIMARY support is patchy — verify before relying on it.
copyq count # how many items in current tab
copyq read 0 # most recent item
copyq read 0 1 2 # multiple
copyq separator $'\n---\n' read 0 1 2 # custom separator between items
Read from a specific tab:
copyq tab "Links" read 0
CopyQ doesn't expose a CLI grep, but eval makes it trivial:
# Find rows matching a regex; print row + content
copyq eval -- '
var n = count();
for (var i = 0; i < n; i++) {
var t = str(read(i));
if (t.match(/TODO/i)) print(i + ": " + t + "\n");
}
'
copyq eval -- '
var n = count();
var out = [];
for (var i = 0; i < n; i++) out.push(str(read(i)));
print(out.join("\n---\n"));
' > ~/clipboard-history.txt
Or dump every tab:
copyq eval -- '
var ts = tabs();
for (var ti = 0; ti < ts.length; ti++) {
tab(ts[ti]);
print("=== " + ts[ti] + " ===\n");
for (var i = 0; i < count(); i++) print(str(read(i)) + "\n---\n");
}
'
copyq eval -- '
var item = getItem(0);
for (var k in item) print(k + " (" + item[k].size + " bytes)\n");
'
There is no copyq tail; emulate with a one-shot Automatic command that prints to stderr, or poll:
# Poll approach (cheap, fine for ad-hoc)
prev=""
while sleep 0.5; do
cur=$(copyq clipboard 2>/dev/null)
if [ "$cur" != "$prev" ]; then
printf '[%s]\n%s\n---\n' "$(date +%T)" "$cur"
prev=$cur
fi
done
For production-quality monitoring, write an Automatic Custom Command that calls notify-send or appends to a logfile — see write-custom-command.
copyq read without a row number defaults to row 0 — easy to confuse with clipboard().clipboard() and read(0) can differ momentarily — the clipboard updates before CopyQ stores the new item.image/png, etc.) print raw bytes; redirect to a file rather than letting them hit the terminal.