| name | manage-tabs-and-items |
| description | Create, rename, reorder, and remove CopyQ tabs; move or copy items between tabs; deduplicate; pin items; and clear history selectively. Use when organising clipboard history into named buckets (Links, Snippets, Code, etc.) or doing bulk cleanup. |
Tabs & Items
CopyQ organises clipboard history into tabs. The default tab is &clipboard. Additional tabs are user-created and persist across restarts.
Tab operations
copyq tab
copyq addTab "Links"
copyq addTab "Snippets"
copyq renameTab "Old" "New"
copyq removeTab "Links"
Bypass GUI confirmation when scripting:
copyq eval -- 'removeTab("Links")'
Switching default target tab for subsequent commands
Every CLI subcommand can be prefixed with tab NAME:
copyq tab "Snippets" add "my snippet"
copyq tab "Snippets" count
copyq tab "Snippets" read 0
Inside scripting:
tab('Snippets');
add('item');
Add items
copyq add "single item"
copyq add "item 1" "item 2" "item 3"
copyq tab "Notes" add "scoped to Notes"
copyq write 0 text/html "<b>bold</b>" text/plain "bold"
Move / copy between tabs
No native "move" subcommand — script it:
copyq eval -- '
var item = getItem(5);
tab("Archive");
var n = count();
setItem(n, item); // append to Archive
tab(""); // back to default
remove(5);
'
For copy (don't remove from source):
copyq eval -- '
var item = getItem(0);
tab("Snippets");
setItem(count(), item);
'
Remove items
copyq remove 0
copyq remove 0 1 2
copyq eval -- '
// Remove rows matching a regex
for (var i = count() - 1; i >= 0; i--) {
if (str(read(i)).match(/^DRAFT:/)) remove(i);
}
'
Iterate descending when removing — removing row N shifts higher rows down by one.
Clear a tab
copyq eval -- '
while (count() > 0) remove(0);
'
Or clear all tabs:
copyq eval -- '
var ts = tabs();
for (var ti = 0; ti < ts.length; ti++) {
tab(ts[ti]);
while (count() > 0) remove(0);
}
'
Deduplicate a tab
copyq eval -- '
var seen = {};
for (var i = count() - 1; i >= 0; i--) {
var t = str(read(i));
if (seen[t]) remove(i);
else seen[t] = true;
}
'
Pin an item
CopyQ supports pinning via the GUI (right-click → Pin). From script:
copyq eval -- '
setItem(0, Object.assign(getItem(0), {"application/x-copyq-pinned": ""}));
'
Pinned items are skipped by maxitems eviction.
Reorder
copyq select 5
For arbitrary moves, getItem + remove + setItem at target row.
Inspect tab structure
copyq eval -- '
var ts = tabs();
for (var i = 0; i < ts.length; i++) {
tab(ts[i]);
print(ts[i] + ": " + count() + " items\n");
}
'