Send iMessage to a loved one from the terminal!
![](/_next/image?url=https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fstock%2Funsplash%2F2PODhmrvLik%2Fupload%2F25758896dfd9e985037ae7d872f001bb.jpeg%3Fw%3D1600%26h%3D840%26fit%3Dcrop%26crop%3Dentropy%26auto%3Dcompress%2Cformat%26format%3Dwebp&w=3840&q=75)
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!