Add the following to your ~/.zshrc
:
function notifyme {
LAST_EXIT_CODE=$?
CMD=$(fc -ln -1)
osascript -e 'on run argv
tell application "System Events"
set frontApp to name of first application process whose frontmost is true
if frontApp is not "Terminal" then