Skip to content

Instantly share code, notes, and snippets.

@miketaylr miketaylr/Usage forked from akahn/Usage
Created Dec 13, 2009

Embed
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["Terminal.app"].keystroke("t", :using => :command_down)
@terminal = app("Terminal")
@tab = @terminal.windows.first.get.tabs.last.get
@terminal.do_script("cd #{directory}", :in => @tab)
end
end
ARGV[0].to_i.times do
Tab.new(ARGV[1] || Dir.pwd)
end
$ 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.