Last active
September 3, 2018 14:17
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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