Skip to content

Instantly share code, notes, and snippets.

@moyashi
Last active August 9, 2024 17:43
Show Gist options
  • Save moyashi/767cadfbc8307273bb47727dfb0785f4 to your computer and use it in GitHub Desktop.
Save moyashi/767cadfbc8307273bb47727dfb0785f4 to your computer and use it in GitHub Desktop.
# Send iMessage from Minibuffer for Textbringer
define_command(:send_imessages) do
f = ->(s) {
["[email protected]", "+81 90 1234 5678"]
}
initial_value = ""
ignore_case = CONFIG[:read_file_name_completion_ignore_case]
to = Utils.read_from_minibuffer("Send iMessage to: ", completion_proc: f,
initial_value: initial_value,
completion_ignore_case: ignore_case)
mes = Utils.read_from_minibuffer("body: ")
`osascript -e '
tell application "Messages"
set targetBuddy to "#{to}"
set targetService to id of 1st account whose service type = iMessage
set textMessage to "#{mes}"
set theBuddy to participant targetBuddy of account id targetService
send textMessage to theBuddy
end tell'`
end
GLOBAL_MAP.define_key("\C-x\C-i", :send_imessages)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment