News for hackers. Stuff that matters.
Re:Useful built-in macOS command-line utilities by hk1337 on Wednesday November 06, 2024 @10:44AM (#42064032)
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"

Re:Useful built-in macOS command-line utilities by ssttoo on Wednesday November 06, 2024 @10:57AM (#42064242)
`open .` works for me too
Re:Useful built-in macOS command-line utilities by hk1337 on Wednesday November 06, 2024 @11:08AM (#42064415)
Yeah, I scrolled a bit and noticed that. Never thought about using just that.
Re:Useful built-in macOS command-line utilities by 1-more on Thursday November 07, 2024 @11:37AM (#42078197)
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.
Re:Useful built-in macOS command-line utilities by nextos on Wednesday November 06, 2024 @12:32PM (#42065860)
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.
Re:Useful built-in macOS command-line utilities by seec on Wednesday November 06, 2024 @03:37PM (#42068957)
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.

Re:Useful built-in macOS command-line utilities by vbezhenar on Wednesday November 06, 2024 @05:37PM (#42070634)
There are extended attributes which could be used for this task.
Re:Useful built-in macOS command-line utilities by seec on Wednesday November 06, 2024 @09:09PM (#42072538)
I don't think xattr works for folders. And you still wouldn't have the fancy presentation you can get with .DS_Store with the graphics and all that jazz.

Of course, they could rethink the whole thing but the point is that it's a legacy thing and at this time it's not worth dedicating much ressource to a solve problem just to remove some mostly invisible files (on UNIXs). It's really easy to have scripts to cleanup for sharing to outside world, even some zip utilities do that automatically.

It can be annoying but it's really not a big deal, I doubt they could come up with something much better while still preserving the functionality and not making another complicated/convoluted proprietary folder format that wouldn't transfer any better to Windows...

Re:Useful built-in macOS command-line utilities by dwaite on Wednesday November 06, 2024 @03:19PM (#42068694)
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.

Re:Useful built-in macOS command-line utilities by codazoda on Wednesday November 06, 2024 @03:24PM (#42068780)
.DS_Store is also a bug. I’m not sure why it hasn’t been fixed. It’s history is quite interesting but I don’t recall where I read about it.
Re:Useful built-in macOS command-line utilities by mdean on Wednesday November 06, 2024 @03:28PM (#42068834)
Re:Useful built-in macOS command-line utilities by nutrie on Wednesday November 06, 2024 @01:26PM (#42066866)
Actually, .DS_Store is very Apple indeed (not that I care much).
Re:Useful built-in macOS command-line utilities by fragmede on Wednesday November 06, 2024 @12:34PM (#42065896)
you can just

    open .
unless you've reconfigured something else to open directories, which most people haven't.
Re:Useful built-in macOS command-line utilities by ilyagr on Wednesday November 06, 2024 @01:17PM (#42066681)
You can also `open -R file` to select that file in Finder.
Re:Useful built-in macOS command-line utilities by luckman212 on Thursday November 07, 2024 @08:03PM (#42083045)
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.