Skip to content

Instantly share code, notes, and snippets.

@dcadenas
Created June 15, 2013 02:27
Show Gist options
  • Select an option

  • Save dcadenas/5786542 to your computer and use it in GitHub Desktop.

Select an option

Save dcadenas/5786542 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
#usage: imsg daniel "hello world"
buddyids = {
daniel: "[email protected]",
elcuervo: "[email protected]"
}
nickname = ARGV[0].to_sym
buddyid = buddyids.fetch(nickname) do
puts("#{nickname} is neither #{buddyids.keys.join(" nor ")}")
exit(1)
end
message = ARGV[1]
applescript = <<HERE
tell application "Messages"
set myid to get id of first service
set theBuddy to buddy "#{buddyid}" of service id myid
send "#{message}" to theBuddy
end tell
HERE
`osascript -e '#{applescript}'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment