The “Lazy Developer” Guide to macOS-to-iPhone Notifications 🚀

Ever been deep in the zone, running a massive script, a long build process, or a complex data migration, only to realize you’re staring at a progress bar like a hypnotized cat?

You want to go grab a coffee, maybe hit the gym, or just walk away from the desk, but you’re haunted by the fear that if the process fails (or finally finishes), you won’t know. You need a nudge. Not a loud, annoying alarm, but a subtle, “Hey, you’re done” haptic tap on your wrist or a simple text on your iPhone.

The Problem with “Modern” Solutions

Usually, people suggest building a full-blown web service, setting up a Push Notification service, or integrating third-party apps. While cool in theory, these often introduce: - Unnecessary Complexity: Why write 50 lines of Node.js when you can write one? - Security Risks: Opening up webhooks or third-party APIs just to say “Task Done” feels like using a sledgehammer to crack a nut. - Maintenance Overhead: You don’t want to debug your notification server when your actual script fails.

The “Keep It Simple, Stupid” (KISS) Approach

If you use macOS, you already have a powerful tool sitting right under your nose: AppleScript.

By leveraging the Messages app, you can send a text to yourself (or anyone else) directly from your terminal. It’s secure, it’s instant, and it uses the infrastructure Apple has already perfected.

Here is the magic spell:

osascript -e 'tell application "Messages" to send "🚀 Task completed successfully!" to buddy "+1234567890"'

(Just replace +1234567890 with your actual phone number or email address!)

How to use it like a pro

Don’t just type it manually. Append it to your long-running commands using the && operator. This ensures the notification only sends if the command actually succeeds.

./my_massive_script.sh && osascript -e 'tell application "Messages" to send "✅ Script finished without errors!" to buddy "+1234567890"'

Or, if you want to know even if it fails:

./my_massive_script.sh && osascript -e '...' || osascript -e 'tell application "Messages" to send "❌ Oh no! Something went wrong." to buddy "+1234567890"'

Final Thoughts

While I often wish Apple provided a dedicated, developer-friendly CLI tool for system-wide push notifications, this little AppleScript hack is the perfect bridge. It’s lightweight, it’s “hacky” in the best way possible, and most importantly, it works.

Now, go grab that coffee but skip on the sugar. You’ve earned it. ☕️

← Blog index