Skip to content

Instantly share code, notes, and snippets.

@henrik
Last active February 26, 2023 15:58
Show Gist options
  • Save henrik/8b002ae46ca96217c32b0824bdc8dda8 to your computer and use it in GitHub Desktop.
Save henrik/8b002ae46ca96217c32b0824bdc8dda8 to your computer and use it in GitHub Desktop.
Raycast script command to send a Messages.app IM to a fixed contact, or just switch to Messages if no argument is provided. Don't forget to customize `theEmail`.
#!/usr/bin/env osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title Send IM
# @raycast.mode silent
# Optional parameters:
# @raycast.icon 💬
# @raycast.author Henrik Nyh
# @raycast.argument1 { "type": "text", "placeholder": "message", "optional": true }
on run argv
-- Customize this.
set theEmail to "foo.barson@example.com"
set theMessage to (item 1 of argv)
if length of theMessage is greater than 0 then
tell application "Messages" to send theMessage to buddy theEmail of (service 1 whose service type is iMessage)
-- Toast output.
"Sent: " & theMessage
else
tell application "Messages" to activate
-- Toast output.
"Switching to Messages"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment