我有一个shell脚本,在OS X上有用户执行权限,但当我双击它时,它在文本编辑器中打开。如何通过双击它来运行它?
当前回答
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.
其他回答
无需使用Platypus等第三方应用。
只需使用脚本编辑器创建一个Apple脚本,并使用命令do shell Script“shell commands”进行直接命令调用或可执行的shell脚本文件,将可编辑的脚本文件安全保存在某个地方,然后导出它以创建应用程序脚本。应用程序脚本可以通过双击或选择栏文件夹启动。
Chmod 774文件名
注意:带有bash脚本的文件名为'filename'的文件没有扩展名
你试过使用.command文件扩展名吗?
你也可以使用RCDefaultApp通过文件扩展名设置默认值:
http://www.rubicode.com/Software/RCDefaultApp/
潜在地,你可以设置.sh打开在iTerm/终端等,这需要用户执行权限,例如
chmod u+x filename.sh
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.
推荐文章
- 访问限制:'Application'类型不是API(必需库rt.jar的限制)
- 为什么在Mac OS X v10.9 (Mavericks)的终端中apt-get功能不起作用?
- 查看PS命令的全部输出
- 确保一次只运行一个shell脚本实例的快速方法
- “你有邮件”的消息在终端,os X
- Mac OS X中的环境变量
- 如何从macOS完全卸载蟒蛇
- 如何在Makefile中设置子进程的环境变量
- 如何让“wc -l”打印没有文件名的行数?
- 有效地测试Linux上的端口是否打开?
- 如何从另一个文件A中删除文件B中出现的行?
- 如何配置Mac OS X术语,使git有颜色?
- Shell脚本删除超过n天的目录
- 如何检查shell脚本中是否存在命令?
- 如何使用查找命令从列表中查找所有具有扩展名的文件?