Firefox already lets you open new URLs from the command line. Is there a way to select an existing tab from the command line, by title or URL?
Yes, there is:
use telnet to connect to the running MozRepl instance:
$ telnet 127.0.0.1 4242
You can also use rlwrap
to enable readline
-like keybindings inside telnet session:
$ rlwrap telnet 127.0.0.1 4242
define a function for searching a tab with a given URL and switching to it. This one from https://github.com/emacsmirror/cedet/blob/master/lisp/cedet/semantic/db-mozrepl.el is pretty cool:
function semanticselecttab(url) {
var numTabs=gBrowser.browsers.length;
for(i=0; i<numTabs-1; i++) {
if(gBrowser.browsers[i].contentDocument.location.href.indexOf(url)>=0) {
gBrowser.tabContainer.selectedIndex=i;
break;
}
}
}
run it like this:
repl> semanticselecttab("https://stackoverflow.com/questions/31055148/select-a-tab-in-firefox-from-command-line")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With