Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CopyQ - Search All Tabs
[Command]
Name=Search All Tabs
Command="
copyq:
// Name for tab for storing matching items.
var search_tab_name = \"Search\"
// Returns true iff item at index matches regex.
function item_matches(item_index, re)
{
var text = str(read(j))
return text && re.test(text)
}
// Ask for search expression.
var match = dialog(\"Search\")
if (!match)
abort()
var re = new RegExp(match)
// Clear tab with results.
try {
removeTab(search_tab_name)
} catch (e) {}
// Search all tabs.
var tab_names = tab()
for (var i in tab_names) {
var tab_name = tab_names[i]
tab(tab_name)
var item_count = count()
// Search all items in tab.
for (var j = 0; j < item_count; ++j) {
// Add matching item to tab with results.
if (item_matches(j, re)) {
var item = getItem(j)
tab(search_tab_name)
setItem(j, item)
tab(tab_name)
}
}
}
show(search_tab_name)"
InMenu=true
Icon=\xf002
Shortcut=Ctrl+Shift+F
@hluk

This comment has been minimized.

Copy link
Owner Author

commented Mar 24, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.