Skip to content

Instantly share code, notes, and snippets.

@andermoran
Created April 12, 2017 18:41
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 andermoran/9f4bfb245f9498a7105b53b63a57cbb8 to your computer and use it in GitHub Desktop.
Save andermoran/9f4bfb245f9498a7105b53b63a57cbb8 to your computer and use it in GitHub Desktop.
Allows sending of an iMessage thru terminal. Can't send message to self, yet...
#!/bin/sh
USAGE=$'Usage: imessage <number> <text>\nExample: message 9121231234 \"Hello!\"'
if [ "$#" -ne "2" ]; then
echo "$USAGE"
exit 1;
fi
exec <"$0" || exit;
for i in {1..12} # Reads the first x lines of the program
do
read v
done
exec /usr/bin/osascript - "$@"; exit # Interprets the following lines as AppleScript
on run {targetBuddyPhone, targetMessage}
tell application "Messages"
set targetService to 1st service whose service type = iMessage
set targetBuddy to buddy targetBuddyPhone of targetService
send targetMessage to targetBuddy
end tell
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment