Comment by hk1337

2 years ago

open -a "Finder" . - open Finder in the current directory.

Standard apps usually just need the name, like Finder and Safari but you can also specify the path "/Applications/DifferentFinder.app"

`open .` works for me too

  • Yeah, I scrolled a bit and noticed that. Never thought about using just that.

    • Also `open -R path/to/file` opens Finder in the containing directory with the file highlighted (and thus scrolled into view). I use this with a script that takes a screen recording and trims some specified seconds off the end and converts it to mp4 to be smaller when I upload into a Github PR description. Easiest to drag and drop the converted file, y'see.

Finder is pretty good, and it's handy to be able to open it from the terminal. But I find it super annoying it litters everything with .DS_Store files and there is no way to turn that off, except for external and network drives. Aside from, obviously, using a different file manager. Very un-Apple.

  • Well those files are to keep the view/presentation settings.

    I guess you could do that centrally with some sort of database but that would open another can of worms; and most importantly you wouldn't be able to transfer a folder and keep its Finder presentation intact.

    Nowadays it's not as useful because of the App Store but when software was only released as .dmg images, it became expected to open a nice layout with graphics presenting the app and a shortcut to the App folder that you would drag'n'drop the app bundle to.

    This presentation relies of .DS_Store to work.

    There are some other use cases like that, it all comes down to a simple fact: Apple has always cared a lot more about how things look than Microsoft ever did, this is a perfect example.

  • The .DS_Store files are not Finder specific; Apple treats everything as a file (including folders), and it exists to supply folders and the files within them with metadata.

    It is just the first time the .DS_Store file is needed is often when the folder is touched by Finder.

Don't forget about "open -b <bundle_id> foo.txt" for example,

    open -b com.sublimetext.4 file.txt

I prefer this vs using the App Name or Path, since those can vary depending on the system or app version. The bundle ID is more robust.

you can just

    open .

unless you've reconfigured something else to open directories, which most people haven't.