This post originated from an RSS feed registered with Ruby Buzz
by James Britt.
Original Post: Quick Firefox Tabs
Feed Title: James Britt: Ruby Development
Feed URL: http://feeds.feedburner.com/JamesBritt-Home
Feed Description: James Britt: Playing with better toys
I spend a lot of time at the CLI. Mostly I’m coding, but it’s lead me to acquire or build assorted utilities to Make Stuff Happen without having to reach for the mouse or otherwise navigate through some menu system.
Early on, maybe as one of my first Ruby programs, I wrote some helpers to open a browser and search Google. It’s fairly trivial; a Google search URL is a fixed URL where the value of q is set to the particular keywords of interest. So my code just grabbed the contents of ARGV, built the URL, and shelled out to Firefox. Or IE; the more interesting part to code was abstracting the detection of OS and browser preference so that the right browser was invoked with the appropriate command format.
Before long, I spun the browser-launching part out to library, and used it construct assorted other browser stunts, such as bring up current TV listings. You can imagine my amazing productivity leap.
Firefox ended up being my browser of choice on both Windows and Linux, and among its multitude of features is its handling of multi-site URLs. If you give Firefox a string that is a pipe-delimited set of URLs, Firefox will open them all, with each site in its own tab. Sweetness.
Over time I assembled a few little scripts to open just such collections of sites for various topics. It’s easy to read in a file listing some sites, build the uber-URL, and spawn Firefox. You can get this same effect straight from Firefox, using bookmarks. Firefox lets you organize bookmarks into folders, and each folder has the option “Open All in Tabs”. But that requires mousinating. Still, having what amounted to duplicate bookmark sets seemed dopey. (Plus Firefox makes it easy to assemble such sets; open a browser, load up assorted tabs with sites of interest, then use “Bookmark All Tabs” to group them in a bookmark folder. Better than hand-editing a text file.)
I was unaware of any way to open a bookmark folder when calling Firefox from the command line, so I wrote yet another browser utility.
Quick Firefox Tabs is a small app that reads in a YAML configuration file and opens Firefox bookmark sets from the CLI. The config file is called .qft and needs to live in whatever location ENV['HOME'] returns.
The code needs the path to your mozilla profile so it can parse bookmarks.html. And it needs the command to execute Firefox.
The :alias entry is optional. I got tired of remembering and typing long-ish bookmark folder names, so sub-keys in the :alias section allow the mapping of nice names to real names.
With this, I can call …
$ qft ruby
... and Firefox will appear with the tabbed pages from my “Cool Ruby Sites!!!” bookmarks folder.
I’ve gem’ed up the code and put it up on neurogami.com.
To install it you’ll need t specify the gem repo source URL:
$ sudo gem i qft --source www.neurogami.com
The code is not deeply clever; it solves a particular need of mine (that is, volatile memory that requires frequent use of reference sites for this and that) in a way that works for me.
I may or may not add more features; what’s likely is that I’ll change the name of the bin script to ff (because that’s easier to type), and have it fall back to launching Firefox with the default home page when given no arguments. And perhaps an option to list all available tab sets would be nice, too. And maybe merging sets when given multiple names; and aliases for those meta-sets.