10

On Mac OS X, some applications will display a notification that appears briefly in the upper-right corner (e.g., when I receive email).

Is there a way to generate a notification from the command-line? In other words, is there a command-line program I can run to display a custom notification, with text of my choice? Ideally, I'd love to be able to run something like

show-notification "Hello world!"

from a shell script and have a notification appear showing the text "Hello world!".


I discovered I can use this answer to display a dialog box in the center of the screen that the user has to click "OK" on, but I'm looking for a notification not a modal dialog box.

marked as duplicate by nohillside May 19 '16 at 5:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

14

The following works:

osascript -e 'display notification "Hello world!" with title "Hi!"'
  • You may also like to add sound name "default" at the end – arsenius Aug 24 '17 at 4:55
  • 1
    I wonder if one could specify a custom image for the notification. – Kentzo Jul 27 '18 at 18:53
  • Where can I read the official documentation about display notification? – Barry Jones May 24 at 5:23

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