Most active commenters
  • seec(3)

←back to thread

700 points yen223 | 31 comments | | HN request time: 1.293s | source | bottom
1. vbezhenar ◴[] No.42058069[source]
Few additions.

open -n file.pdf : opens new instance of Preview application which is useful if you want to open the same file twice (for example to look at different pages at once).

caffeinate -d : prevents display turning off, useful if you want to look at display without moving mouse.

replies(9): >>42058131 #>>42059558 #>>42059666 #>>42060870 #>>42062814 #>>42064032 #>>42068484 #>>42068855 #>>42069659 #
2. wwader ◴[] No.42058131[source]
open -a is nice, i use it with alias, ex:

  alias qt='open -a "quicktime player"'
  alias vlc='open -a "vlc"'
replies(1): >>42064357 #
3. mjs ◴[] No.42059558[source]
Does `open` give focus? It used to, but since a few releases ago the app opens in the background, which is pretty annoying.

My poor workaround is to use osascript: `tell application "System Events" to set frontmost of process "Finder" to true`

replies(2): >>42060712 #>>42068883 #
4. troupo ◴[] No.42059666[source]
`caffeinate -disu` is the best combination (that is, enable all options): your laptop won't go to sleep, won't dim the screem etc.
5. masswerk ◴[] No.42060712[source]
Apparently, it does. There is a -g flag (background) to prevent focus.
6. 1ncorrect ◴[] No.42060870[source]
I use this all the time:

open -a <GUI Application> <File>

Handy for distinguishing between editing and consuming media.

7. alsetmusic ◴[] No.42062814[source]
Also, `cd .` to open the current directory in a Finder window.

Not mine (found online years ago), but here's the opposite. `cd` into the frontmost Finder window:

  cd "$(osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)')";
replies(2): >>42062836 #>>42064862 #
8. kps ◴[] No.42062836[source]
You mean `open .`
replies(1): >>42068896 #
9. hk1337 ◴[] No.42064032[source]
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"

replies(4): >>42064242 #>>42065860 #>>42065896 #>>42066681 #
10. ssttoo ◴[] No.42064242[source]
`open .` works for me too
replies(1): >>42064415 #
11. FabHK ◴[] No.42064357[source]
At least for me (I've installed vlc via homebrew), there is a vlc binary in the PATH, and I can just vlc <filename>
replies(1): >>42066842 #
12. hk1337 ◴[] No.42064415{3}[source]
Yeah, I scrolled a bit and noticed that. Never thought about using just that.
13. sneak ◴[] No.42064862[source]
You can also just drag the proxy icon onto the terminal window for its path, ie “cd “ <drop>, enter.
replies(1): >>42065539 #
14. kstrauser ◴[] No.42065539{3}[source]
I use that all the time. You can also cmd-c copy a file in Finder then paste into the terminal to get its path.
15. nextos ◴[] No.42065860[source]
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.
replies(4): >>42066866 #>>42068694 #>>42068780 #>>42068957 #
16. fragmede ◴[] No.42065896[source]
you can just

    open .
unless you've reconfigured something else to open directories, which most people haven't.
17. ilyagr ◴[] No.42066681[source]
You can also `open -R file` to select that file in Finder.
18. qrios ◴[] No.42066842{3}[source]
The point here is to open a document with an app not assigned as default for the given mime-type by file name extension.
19. nutrie ◴[] No.42066866{3}[source]
Actually, .DS_Store is very Apple indeed (not that I care much).
20. impalallama ◴[] No.42068484[source]
caffeinate -d is incredibly useful for work... uh reasons
replies(1): >>42069639 #
21. dwaite ◴[] No.42068694{3}[source]
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.

22. codazoda ◴[] No.42068780{3}[source]
.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.
replies(1): >>42068834 #
23. mdean ◴[] No.42068834{4}[source]
https://www.arno.org/on-the-origins-of-ds-store linked from original Hacker News thread: https://news.ycombinator.com/item?id=40870357
24. seec ◴[] No.42068855[source]
That's one of macOS pitfalls: the inability to open 2 instances of the same app, simply using the default GUI is annoying sometimes.

I think Windows is right in that matter...

25. justletmein ◴[] No.42068883[source]
Isn’t open opening apps in the background a consequence of having “secure keyboard entry” enabled in Terminal.app?
26. alsetmusic ◴[] No.42068896{3}[source]
Yeah, I had just woke up. Drat.
27. seec ◴[] No.42068957{3}[source]
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.

replies(1): >>42070634 #
28. JasserInicide ◴[] No.42069639[source]
Jiggler is better for that at least from a set-it-and-forget-it perspective vs. caffeinate where you have to manually set it.
29. beancookies ◴[] No.42069659[source]
Another useful caffeinate tip is the `-w` option.

You can use it to pass a pid to keep the computer awake until that process completes. I use it for longer-running scripts that I don't want interrupted

30. vbezhenar ◴[] No.42070634{4}[source]
There are extended attributes which could be used for this task.
replies(1): >>42072538 #
31. seec ◴[] No.42072538{5}[source]
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...