Skip to content

Instantly share code, notes, and snippets.

@miketaylr miketaylr/Usage

forked from akahn/Usage
Created Dec 13, 2009
What would you like to do?
#!/usr/bin/env ruby
require 'rubygems'
require 'appscript' # gem install rb-appscript
class Tab
include Appscript
def initialize(directory)
app("System Events").application_processes[""].keystroke("t", :using => :command_down)
@terminal = app("Terminal")
@tab =
@terminal.do_script("cd #{directory}", :in => @tab)
ARGV[0].to_i.times do[1] || Dir.pwd)
$ spawn 3
# => open 5 new Terminal tabs, cd to the current directory
$ spawn 5 ~/Code/project-x
# => Open 5 new Terminal tabs, cd to ~/Code/project-x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.