Created
April 12, 2017 18:41
-
-
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...
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
#!/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