Skip to content

Instantly share code, notes, and snippets.

@4rc0s
Forked from subtleGradient/toggle_app
Created January 2, 2010 22:10
Show Gist options
  • Save 4rc0s/267696 to your computer and use it in GitHub Desktop.
Save 4rc0s/267696 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# toggle_app
# Toggle the visibility of any app on Mac OS X
# Use with Quicksilver or something to toggle with shortcut keys
#
# by: Thomas Aylott -- SubtleGradient.com
# license: MIT
#
if [ ! -n "$1" ]
then
echo "Usage: `basename $0` AppName" 1>&2
exit $E_BADARGS
fi
osascript\
-e "if frontmost of the application \"$1\" then"\
-e "tell application \"System Events\" to set visible of process \"$1\" to false"\
-e "else"\
-e "tell application \"$1\" to activate"\
-e "end if"\
|| exit 1
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment