Send iMessage to a loved one from the terminal!

mkdir ~/bin

Now let's go to it:

cd ~/bin and create a file text.sh

#!/bin/bash

MESSAGE=$1
# Replace with their number (be sure to include the +1)
PHONE_NUMBER=+11234567

if [ "$#" -ne 1 ]; then
     echo "Usage: $0 MESSAGE"
     exit 1
fi

osascript -e "tell application \"Messages\" to send \"$MESSAGE\" to buddy \"    $PHONE_NUMBER\""

Now we need to make the file executable:
chmod +x text.sh

Now we can use it!

./text.sh "I LOVE YOU"

Alias

To alias it so that you could say something like rach "I LOVE YOU"

Add to your .zshrc or .bashrc the following:

# local bin
export PATH="$HOME/bin:$PATH"
alias rach='text.sh'

Now we can say rach "I LOVE YOU" and it sends!

0
Subscribe to my newsletter

Read articles from Reilly O'Donnell directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Reilly O'Donnell
Reilly O'Donnell

If you've got any questions feel free to DM on Twitter @reillyjodonnell