title: Bringing an OS X application to the front even if it's a different Mission Control space
body: <p>What I'm trying to do is switch to an application reliably, even if it's open in a different space, using a shell script. For example, let's assume I'm in space 1, and there is a Safari window open in space 2 but not in space 1. I want to be able to switch to the appropriate space in order make make Safari active. Currently I'm using AppleScript:</p>
  
  <pre><code>osascript -e "
  tell application \"Safari\"
      activate
  end tell
  "
  </code></pre>
  
  <p>But this only makes the menu bar switch to Safari, instead of moving to the space that contains the Safari window.</p>