我有一个shell脚本,在OS X上有用户执行权限,但当我双击它时,它在文本编辑器中打开。如何通过双击它来运行它?


当前回答

Chmod 774文件名

注意:带有bash脚本的文件名为'filename'的文件没有扩展名

其他回答

你也可以使用RCDefaultApp通过文件扩展名设置默认值:

http://www.rubicode.com/Software/RCDefaultApp/

潜在地,你可以设置.sh打开在iTerm/终端等,这需要用户执行权限,例如

chmod u+x filename.sh

你试过使用.command文件扩展名吗?

Chmod 774文件名

注意:带有bash脚本的文件名为'filename'的文件没有扩展名

无需使用Platypus等第三方应用。

只需使用脚本编辑器创建一个Apple脚本,并使用命令do shell Script“shell commands”进行直接命令调用或可执行的shell脚本文件,将可编辑的脚本文件安全保存在某个地方,然后导出它以创建应用程序脚本。应用程序脚本可以通过双击或选择栏文件夹启动。

First in terminal make the script executable by typing the following command: chmod a+x yourscriptname Then, in Finder, right-click your file and select "Open with" and then "Other...". Here you select the application you want the file to execute into, in this case it would be Terminal. To be able to select terminal you need to switch from "Recommended Applications" to "All Applications". (The Terminal.app application can be found in the Utilities folder) NOTE that unless you don't want to associate all files with this extension to be run in terminal you should not have "Always Open With" checked. After clicking OK you should be able to execute you script by simply double-clicking it.