Skip to content

Instantly share code, notes, and snippets.

@troyp
Last active September 3, 2018 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troyp/ff64f37d695bb4549e96 to your computer and use it in GitHub Desktop.
Save troyp/ff64f37d695bb4549e96 to your computer and use it in GitHub Desktop.
Provides the command tgroup-moveselected, which moves all tabs matching a given regular expression to the group with specified id.
" tgroup-moveselected.penta
" Provides the command tgroup-moveselected, which moves all tabs matching a
" given regular expression to the group with specified id.
" eg. :tgroup-moveselected "penta" "pentadactyl"
" moves any tabs whose label matches /pentadactyl/ to the group with id "penta"
" Requires the TabGroupie plugin.
group TabGroupie
command! tgroup-moveselected
\ -nargs=+
\ -description "move tabs matching regex to a given group"
\ -js tgroupMoveSelected(args[0], RegExp(args[1]))
js <<EOF
function getPlugin(s) {
for (x in plugins.contexts) {
if (x.contains(s))
return plugins.contexts[x][s];
}
}
var TabGroupie = getPlugin("TabGroupie");
function matchingTabs(rx) {
var alltabs = tabs.allTabs;
var alltabs = gBrowser.getTabsToTheEndFrom(0);
function matches(t) {
return rx.test(t.label.toLowerCase());
}
var matching = alltabs.filter(matches);
return matching;
}
function matchingTabsInGroup(rx) {
var alltabs = gBrowser.getTabsToTheEndFrom(0);
function matches(t) {
return rx.test(t.label.toLowerCase());
}
var matching = alltabs.filter(matches);
return matching;
}
function tgroupMoveSelected (targetgrp, rx) {
var matching = matchingTabs(rx);
var tgrpId = TabGroupie.getIdByTitle(targetgrp);
var i, t;
for (i=0; i<matching.length; ++i) {
t = matching[i];
TabView.moveTabTo(t, tgrpId);
}
TabView.hide();
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment