Search code examples
macospopupterminalapplescriptalert

How do I make a Mac Terminal pop-up/alert? Applescript?


I want to be able to have my program display an alert, notice, whatever that displays my custom text. How is this done? Also, is it possible to make one with several buttons that sets a variable?

Similar to batch's: echo msgbox""<a.vbs&a.vbs


Solution

  • Use osascript. For example:

    osascript -e 'tell app "Finder" to display dialog "Hello World"' 
    

    Replacing “Finder” with whatever app you desire. Note if that app is backgrounded, the dialog will appear in the background too. To always show in the foreground, use “System Events” as the app:

    osascript -e 'tell app "System Events" to display dialog "Hello World"'
    

    Read more on Mac OS X Hints.