Show package contents from command line

When working at the terminal, I often use the open . command to open a finder window showing the current working directory. But if the current directory is actually a package, like a .app application or a .vmwarevm virtual machine, open . launches the application or the virtual machine instead.

How can I open a finder window showing the contents of a specified package?

I’ve tried open -A /System/Library/CoreServices/Finder.app ., but that didn’t work.


Solution 1:

Using open -R for the first file in the bundle would work even if the bundle doesn't have a Contents directory:

reveal() (
  shopt -s nullglob
  for f; do
    a=("$f"/*)
    [[ -d $f && ${#a} != 0 ]] && open -R -- "${a[0]}" || open -R -- "$f"
  done
)

It might be easier to just type open -R and the path of some file inside the bundle though. You can bind menu-complete in .inputrc to make it easier to insert the path of the first file.

Solution 2:

You can simply cd into the package to open it in Terminal, then open Contents to open the contents in Finder.

For example, to open the contents of Safari.app in Finder, you can run the following:

cd /Applications/Safari.app
open Contents

Solution 3:

open -R *

opens the package in Finder. But beware: it also selects every contained file and folder. In general this might be OK for you as most of the times it's just Contents.

Looks like this: Schalalalalala