简体   繁体   中英

How to find the executable file for “open” command in Mac?

I would like to open many of my programs through the mac terminal, since I use that frequently. For example, I want to be able to launch "chrome" from the Mac OSx terminal by typing open chrome .

Of course, this would only work if the environmental variable path knows where to find the executable file for this program. I've tried searching for the executable file for applications (such as chrome) using this:

find . -iname "*chrome*" 

but none of the results work ( and there were a lot of results, of course). So, I'm wondering what is the best way to either

1) find the executable to add to the PATH environmental variable or 2) launch an application via some other method

Thanks.

Generally as far as I've seen, you can launch practically any application like so:

# binary file:
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome

# open .app:
open /Applications/Google\ Chrome.app/

# binary + variable:
appName="Google Chrome"
"/Applications/$appName.app/Contents/MacOS/$appName"

# open + variable:
appName="Google Chrome"
open "/Applications/$appName.app/"

Hope this helps! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM