14

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.

  • Not at a Mac to test, but have you tried simply using cd /System/Library/CoreServices/Finder.app? If it doesn't work, I'll remove the comment. – stuffe Sep 26 '13 at 15:07
  • I'd wager a guess open -a Finder . doesn't work because when you double click on an App Bundle within Finder, it launches the app :). – Jason Salaz Oct 1 '13 at 18:48
3

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.

9

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
  • 1
    Nope, not all packages have a Contents folder—.vmwarevm virtual machines sure don’t. – andrew Sep 26 '13 at 15:42
  • Just files. – andrew Sep 26 '13 at 16:29
  • Another kind of bundle with no Contents folder is the .xcodeproj bundle. You can get an example here. – andrew Sep 26 '13 at 19:20
  • 2
    The Contents bit is just an example, performing a cd into the .app file is what you are looking for, regardless of the app bundles eventual contents. – stuffe Sep 26 '13 at 21:13
1
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

  • 2
    Opening * seems like a very bad idea, especially without cautioning people on what it would do in the wrong directory (and how would someone that doesn't get directories even know which one they are in). Should this perhaps be a comment on this other answer? – bmike Sep 26 '13 at 17:15
  • @bmike I guess you forgot the -R option... – Max Ried Sep 26 '13 at 18:02
0
open -R .

From

man open

-R, --reveal Selects in the Finder instead of opening.

-1

From the finder, right click on the application and choose 'Show Contents". The opens the app and you can then navigate thru the enclosed folders.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .