MacOS – How to Close an OS X Application from Command Line Using Alias in .bash_profile

.bash-profilealiascommand linemacos

I found the following shell script that can be used to tell an OS X application to quit:

#!/bin/sh

echo | osascript <<EOF
tell application "$*"
  quit
end tell
EOF

I have several simple alias commands in my .bash_profile and would like to add a "quit" command there instead of using this script. I created the following, but it doesn't work:

alias quit='osascript -e "quit application \"$1\""' 

I'm sure I've munged the command. Any advice?

Best Answer

Use a function instead:

function quit {
osascript <<EOF
  tell application "$*" to quit
EOF
}
Related Question