Skip to content

Instantly share code, notes, and snippets.

@miketaylr
Forked from akahn/Usage
Created December 13, 2009 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketaylr/255168 to your computer and use it in GitHub Desktop.
Save miketaylr/255168 to your computer and use it in GitHub Desktop.
#!/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