| name | clipboard-inspect |
| description | 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. |
Inspect Clipboard & History
Current clipboard
copyq clipboard
copyq clipboard text/html
copyq clipboard text/uri-list
copyq clipboard image/png > /tmp/clip.png
List MIME types currently on the clipboard:
copyq eval -- 'print(clipboard("?"))'
X11 PRIMARY selection (mouse-selected text)
copyq selection
Only meaningful on X11 sessions. On Wayland, PRIMARY support is patchy — verify before relying on it.
History
copyq count
copyq read 0
copyq read 0 1 2
copyq separator $'\n---\n' read 0 1 2
Read from a specific tab:
copyq tab "Links" read 0
Filter / search
CopyQ doesn't expose a CLI grep, but eval makes it trivial:
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");
}
'
Dump full history of a tab to a file
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");
}
'
Inspect item metadata (all MIME types)
copyq eval -- '
var item = getItem(0);
for (var k in item) print(k + " (" + item[k].size + " bytes)\n");
'
Watch new clipboard events live
There is no copyq tail; emulate with a one-shot Automatic command that prints to stderr, or poll:
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.
Common gotchas
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.
- Binary MIME types (
image/png, etc.) print raw bytes; redirect to a file rather than letting them hit the terminal.