Open sesame

Here’s a simple little script that saves me a lot of time:


if [ -z "$1" ]; then
  echo "usage: $0  [ Preferences |  ]"
  base=~/Library/Application\ Support/iPhone\ Simulator/
  app=`ls -1td "$base/"*"/$apps/"*"/$" | head -1`
  if [ -n "$app" ]; then
    dir=`dirname "$app"`
    if [ "$2" = "Preferences" ]; then
      open "$dir/Library/Preferences"
      open "$dir/Documents/$2"

Put this script somewhere on your PATH and name it opensim. Use it to find the most recent application loaded in the simulator and open the Preferences, Documents or a named document in the Finder.

For example, to open the current Documents folder for an application in the iPhone Simulator, just do this:

$ opensim Thunderbird

To open a document within that folder, you can do this:

$ opensim Thunderbird chockenberry.db
$ opensim Thunderbird accounts.plist

You can easily get to your preferences folder with:

$ opensim Thunderbird Preferences

Notice how I haven’t mentioned a GUID in this essay? That’s the feature…