Created
December 12, 2009 22:25
-
-
Save akahn/255109 to your computer and use it in GitHub Desktop.
Open n Terminal.app tabs in current or x directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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