如何通过双击在OS X中运行Shell脚本? [英] How to run a shell script in OS X by double-clicking?

查看:90
本文介绍了如何通过双击在OS X中运行Shell脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个外壳脚本,该脚本在OS X上具有用户执行权限,但是当我双击它时,它将在文本编辑器中打开.如何通过双击使它运行?

I have a shell script that has user execution permission on OS X, but when I double click on it, it opens in a text editor. How can I get it to run by double-clicking it?

推荐答案

  • 首先在终端中输入以下命令以使脚本可执行:

    • First in terminal make the script executable by typing:

      chmod a+x (yourscriptname)
      

    • 然后,在Finder中,右键单击您的文件,然后选择打开方式",然后选择其他...".

    • Then, in Finder, right-click your file and select "Open with" and then "Other...".

      在此处选择要在其中执行文件的应用程序,在这种情况下,它将是Terminal.为了能够选择终端,您需要从推荐的应用程序"切换到所有应用程序". (可以在实用工具"文件夹中找到Terminal.app应用程序)

      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.

      这篇关于如何通过双击在OS X中运行Shell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆