Skip to content

Instantly share code, notes, and snippets.

@roldershaw
Last active March 1, 2022 19:34
Show Gist options
  • Save roldershaw/7311547 to your computer and use it in GitHub Desktop.
Save roldershaw/7311547 to your computer and use it in GitHub Desktop.
Send iMessages from the command line using Bash and AppleScript

Sending iMessages from the command line using Bash and AppleScript.

Usage:

Change the [email protected] email to the address you use for iMessage.

and call the script with the first parameter being the recipient and the second one being your message, for example:

$ ./imsg [email protected] "Hello World!"
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ] ; then
echo "Usage: imsg [address] [message]"
else
/usr/bin/osascript -e 'tell application "Messages"
send "'"$2"'" to buddy "'"$1"'" of service "E:[email protected]"
end tell'
echo "Sent"
fi
@Keyaku
Copy link

Keyaku commented Jul 4, 2021

Thank you for this script, but it's giving me the following
26:117: execution error: Messages got an error: Invalid key form. (-10002)

Any ideas how to fix it?

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