macOS Bash – What is the ‘xmessage’ Command Equivalent?

bashunix

For Linux, there is a command xmessage which displays a message in a window. Does anyone know what is the equivalent one on macOS?

Best Answer

AppleScript

On macOS, displaying simple dialogs is possible with AppleScript:

/usr/bin/osascript -e "display dialog \"Hello world\""

See Displaying Dialogs and Alerts in Apple's Mac Automation Scripting Guide.

Additional buttons, choices, and other limited interface elements can be added:

set theDialogText to "An error has occurred. Would you like to continue?"
display dialog theDialogText buttons {"Don't Continue", "Continue"} default button "Continue" cancel button "Don't Continue"

AppleScript dialog box