如何在Mac中找到"open"命令的可执行文件?

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

我想通过 mac 终端打开我的许多程序,因为我经常使用它。例如,我希望能够通过键入 open chrome 从 Mac OSx 终端启动 "chrome"。

当然,这只有在环境变量path 知道在哪里可以找到该程序的可执行文件的情况下才有效。我尝试使用以下方法搜索应用程序(例如 chrome)的可执行文件:

find . -iname "*chrome*" 

但 none 的结果有效(当然还有很多结果)。所以,我想知道

的最佳方法是什么

1) 找到可执行文件添加到PATH环境变量 要么 2) 通过其他方法启动应用程序

谢谢。

据我所知,您几乎可以像这样启动任何应用程序:

# 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/"

希望对您有所帮助! :)