Mac – Bash – Create Pop Up Message

email me

Creates a non-intrusive dialog box via the Finder app.

Dialog box will be available here — The Finder app will be jumping up and down.

#!/bin/bash
osascript -e 'tell app "Finder" to display dialog "Software installed. Please restart your computer." buttons {"OK"}'

 

 

Creates a dialog box using System Event.

Dialog box will just appear on desktop

#!/bin/bash

# Dialog Function
function msgBox() {
  osascript <<EOT
    tell app "System Events"
      display dialog "$1" buttons {"OK"} default button 1 with icon caution with title "$(basename $0)"
      ## icon 0=stop,icon 1=software,icon 2=caution
      return  -- Suppress result
    end tell
EOT
}

msgBox "Software has been installed. Please restart your computer!"

 

Notes

killall Terminal

osascript -e ‘tell application “Terminal” to quit’

echo -n -e “\033]0;msgBox\007”
osascript -e ‘tell application “Terminal” to close (every window whose name contains “msgBox”)’ &

closeWindow() {
/usr/bin/osascript << _OSACLOSE_
tell application “Terminal”
close (every window whose name contains “msgBox.sh”)
end tell
delay 0.3
tell application “System Events” to click UI element “Close” of sheet 1 of window 1 of application process “Terminal”
_OSACLOSE_
}