I'd like to be able to display a notification window in OS X from within a script. The script will be running in background, so the notification should not go to the terminal but instead be displayed in a dialog window.

What I found so far


On Linux I'd probably use xmessage or one of its variants for this. But on OS X, starting the bulky X server just for this task seems both overkill and too slow for my taste.

Finder dialog

I've found a similar question in this forum thread, where the “accepted” reply suggested this command:

osascript -e 'tell app "Finder" to display dialog "Hey!"'

But on my OS X , the resulting dialog isn't displayed immediately. Instead, the Finder icon starts to bounce, and the dialog becomes visible only after I click on the icon. Too many mouse clicks, too disruptive.


There is an answer on Super User which suggests a tool called terminal-notifier. Unfortunately that appears to only work for OS X , so it won't help in my case.


So is there some tool, either included in OS X or freely available, which allows displaying a small dialog to the user without too much overhead?


One option is to tell a background process like SystemUIServer to display the dialog:

osascript -e 'tell application "SystemUIServer"
display dialog "message"
activate application (path to frontmost application as text)'

You can also tell the frontmost application to display a dialog, but it's not shown immediately if the application is not responding. If MPlayer OS X is frontmost, text dialogs don't accept any keyboard input.

osascript -e 'tell application (path to frontmost application as text)
display dialog "message"
  • The first approach has the drawback that it will raise all windows of the given application, which I find slightly annoying. But the second approach is the best I've seen so far. Apps not responding should be rare enough that I won't worry about these. – MvG Nov 30 '12 at 12:18


tell application "System Events" to display dialog "Plug the Digispark into the USB port." buttons {"OK"} with icon caution

Tested on OS X 10.8.2

  • Sounds like I need to learn osascript – Edward Falk Jul 22 '16 at 18:45
  • Question: Adding the clause buttons {"OK"} causes the dialog to not get focus when it pops up. Leaving it out gives you a Cancel button, which we don't want, but at least the dialog gets focus. Is there a way to get focus, even when using that clause? – Edward Falk Jul 22 '16 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .