I know that if I'm using the mac command line, I can open a file with the command
open file
Furthermore, if I know the name of the application with which I want to open the file, I should be able to open it with
open -a "Application" file
However, I can't figure out how to know what names I have available for "Applications," or how I might be able to add different applications to those that I can call in this way. Any pointers towards the right direction (or even what I could have done to figure this out on my own) would be so appreciated!
CodePudding user response:
I have often wondered myself and hope this crude method doesn't stop anyone who knows the actual answer from responding. Please don't rush to accept this work-around else folk will lose interest in sharing the proper answer.
I have two crude, clumsy methods...
Method 1: I can look for all things called xxx.app
whilst discarding errors, like this:
find / -name "*.app" 2> /dev/null
Method 2: I get a list of all running processes and save it in a file, then I start the app I am looking for by double-clicking it, or from Spotlight, then I get a new list of what's running and compare to see what's new:
ps -aef > /tmp/a
# Launch app
ps -aef > /tmp/b
opendiff /tmp/{a,b}
There's also a bundleId
that you can pass to open
, and you can use mdls
command on an app to get its bundleId
- try it on Pages with:
mdls /Applications/Pages.app
So you can presumably use mdfind
somehow to get bundleIds of everything that might be an app. Example of mdfind
here.
The following gets a list of all things that Apple thinks might be application bundles:
mdfind "kMDItemContentType == 'com.apple.application-bundle'"
CodePudding user response:
Method 1
- Click the Apple icon at the top-left corner on your screen.
- Click "About This Mac"
- Click "System Report"
- Navigate to "Software/Applications"
Method 2
Use this method if your prefer CLI over GUI.
system_profiler -json SPApplicationsDataType | jq -r '.SPApplicationsDataType[] | ._name'
Method 3
This is slow but it works.
find / -name *.app