Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created January 1, 2010 19:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save subtleGradient/267219 to your computer and use it in GitHub Desktop.
Save subtleGradient/267219 to your computer and use it in GitHub Desktop.
toggle_app — Toggle the visibility of any app on Mac OS X — Use with Quicksilver or something to toggle with shortcut keys
#!/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