by vbezhenar · 2y ago · 0 comments
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.
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
open -a <GUI Application> <File>
Handy for distinguishing between editing and consuming media.
alias qt='open -a "quicktime player"'
alias vlc='open -a "vlc"'Standard apps usually just need the name, like Finder and Safari but you can also specify the path "/Applications/DifferentFinder.app"
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.
It is just the first time the .DS_Store file is needed is often when the folder is touched by Finder.
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. open .
unless you've reconfigured something else to open directories, which most people haven't.I think Windows is right in that matter...
My poor workaround is to use osascript: `tell application "System Events" to set frontmost of process "Finder" to true`
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)')";