How to Send an iMessage From Command Line

By  on  

As somewhat of a recluse, believe me when I say that text messages, instant messenger, and iMessage have relieved me of loads of anxiety and wasted time with short, meaningless voice chat. It's been a decade since these communication types have become popular so we've moved on from appreciate these technologies to trying to optimize them.

My family and friends are deep into the Apple ecosystem so I frequently receive texts via iMessage (or Message on Mac); at the same time, I'm within a Mac terminal much of my day,. At this point, it's a bit of a hardship (poor me!) to even open the Messages app, and I'd prefer to send messages via command line.

To send a message via command line, you can type the following:

osascript -e 'tell application "Messages" to send "DWB and MooTools FTW!" to buddy "David Walsh"'

I'd recommend creating an alias for this command, which would accept a user and a message.

Command line wins are amazing time savers. Finding a way to accomplish tasks with your usual workflow will make you infinitely more efficient!

Recent Features

  • By
    Being a Dev Dad

    I get asked loads of questions every day but I'm always surprised that they're rarely questions about code or even tech -- many of the questions I get are more about non-dev stuff like what my office is like, what software I use, and oftentimes...

  • By
    I’m an Impostor

    This is the hardest thing I've ever had to write, much less admit to myself.  I've written resignation letters from jobs I've loved, I've ended relationships, I've failed at a host of tasks, and let myself down in my life.  All of those feelings were very...

Incredible Demos

  • By
    Morphing Elements Using MooTools and CSS

    Morphing an element between CSS classes is another great trick the MooTools JavaScript library enables you to do. Morphing isn't the most practical use of MooTools, but it's still a trick at your disposal. Step 1: The XHTML The block of content that will change is...

  • By
    MooTools Kwicks Plugin

    I wrote a post titled Get Slick with MooTools Kwicks ages ago. The post was quite popular and the effect has been used often. Looking back now, the original code doesn't look as clean as it could. I've revised the original...

Discussion

    Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!