Have you ever closed an application after hitting CMD-Q by mistake? I have, way too many times.

At some point I decided to address this issue and create the following AppleScript, which runs on CMD-Q thanks to keyboard remapping via BetterTouchTools.

The script displays a simple warning and quit the application on confirmation.

  1. Open AppleScript
  2. Past the code below
  3. Save as ~/.quit_front_app.scpt
  4. Run osascript ~/.quit_front_app.scpt
  5. There is no 5
tell application "System Events"
	set frontApp to name of first application process whose frontmost is true
	display dialog "Quit?"
end tell
tell application frontApp to quit