MATTENOBLE

rubygem

Tabby - iTerm2 Environments

If you’ve ever created a Jekyll site with, say, SASS and Coffeescript,
you know how annoying it is to set up your terminal environment every time. Open a tab, cd to your project, open a new tab, jekyll --server --auto, open yet another tab, cd to your project, sass --watch whatever.sass:whatever.css, etc.

I got tired of doing that multiple times per day, week, whatever. And so, Tabby was born.

I created Tabby for two purposes, first to solve the problem described above and second, to play around with the idea of pure Ruby configuration. There’s no crazy DSL (sorta), no YAML, no hassle; just Ruby in all it’s glory.

A Quick Tutorial

With Tabby, you set up Projects. Projects are just collections of iTerm2 tabs and what each one runs. Let’s walk through creating my blog environment. First, create the project:

$ tabby create blog

This will open up your new project in whatever you have $EDITOR set to. Tabby assumes you use ~/Dev as your project directory because, well frankly, I do. It gives you a skeleton for your project right off the bat:

class Blog < Tabby::Base
  basedir "~/Dev/blog"

  def server
    exec "rails s"
  end
end

basedir is the root of your project. Tabby takes each method in your project class and makes it a tab. The tab gets the name of the method. So above, we’d have a tab created and titled “server”. It would immediately run rails s.

Since we’re making a Jekyll blog, we can get rid of the Rails tab. We do want to have the Jekyll server running though and also SASS and Coffeescript.

class Blog < Tabby::Base
  basedir "~/Dev/blog"

  def jekyll
    exec "jekyll --server --auto"
  end

  def sass
    exec "sass --watch public/sass:public/stylesheets"
  end

  def coffee
    exec "coffee --watch -c public/coffee/ -o public/javascript/"
  end
end

So now every time you go to work on your blog, just kick it off with:

$ tabby open blog

and you’ll get:

tabby blog environment

Usage

Here’s a quick run down of the other commands, straight from the horse’s mouth:

tabby create [project]  # Creates an empty project config.
tabby edit [project]    # Opens the project config with $EDITOR.
tabby list              # List all projects.
tabby open [project]    # Starts up the environment for a project.