Skip to content

Instantly share code, notes, and snippets.

Created January 6, 2023 23:09
What would you like to do?
Hide and quit macOS applications in bash/zsh using AppleScript via osascript
function quit_apps() {
for app in $@; do
echo "Quitting $app..."
osascript -e "with timeout of 30 seconds
quit app \"$app\"
end timeout"
if [ $? -ne 0 ]; then
# if the application did not quit on it's own, let's force it!
killall "$app"
function hide_apps() {
for app in $@; do
echo "Hiding $app..."
osascript -e "tell application \"System Events\"
set visible of application process \"$app\" to false
end tell"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment