Skip to content

Instantly share code, notes, and snippets.

@caldwell
Created December 14, 2012 20:52
Show Gist options
  • Save caldwell/4288558 to your computer and use it in GitHub Desktop.
Save caldwell/4288558 to your computer and use it in GitHub Desktop.
A simple function to call Applescript from Ruby.
def osascript(script)
system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
end
@caldwell
Copy link
Author

Usage:

osascript <<-END
  tell application "Finder"
    display dialog "Hello"
  end tell
END

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