Skip to content

Instantly share code, notes, and snippets.

@danielwestendorf
Created June 2, 2011 19:07
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 danielwestendorf/1005066 to your computer and use it in GitHub Desktop.
Save danielwestendorf/1005066 to your computer and use it in GitHub Desktop.
framework 'Foundation'
framework 'ScriptingBridge'
terminal = SBApplication.applicationWithBundleIdentifier("com.apple.terminal")
load_bridge_support_file 'Terminal.bridgesupport' #load the bridge support file
new_tab = terminal.classForScriptingClass("tab").alloc #create a new tab instance
terminal.windows.first.tabs.addObject(new_tab) #add the tab to the first window
--> RuntimeError: NSInvalidArgumentException: *** -[SBElementArray addObject:]: can't add an object that already exists.
@RobertLowe
Copy link

Inject something into a tab:

# scripting into a tab:
terminal.windows.first.tabs.first.setSelected true
terminal.performSelector( :'doScript:in:', withObject:'echo hello', withObject:terminal.windows.first)

# open a new window (but not a new tab :( )
terminal.performSelector( :'doScript:in:', withObject:'echo hello', withObject:nil)

Maybe merbist knows, I'd really like to figure how to open a tab...

@danielwestendorf
Copy link
Author

danielwestendorf commented Jun 6, 2011 via email

@RobertLowe
Copy link

Hacking with macruby is brutal and awesome.

No problem! If you're interested checkout my Mynu gem, I recently expanded it with some basic terminal support:

https://github.com/RobertLowe/mynu/blob/master/examples/terminal.rb
https://github.com/RobertLowe/mynu/blob/master/lib/mynu/support/terminal.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment