OSX 将 shell 脚本与文件扩展名相关联?
我想将 .exe 文件扩展名与启动 wine 的 shell 脚本关联起来。最好的方法是什么?
根据我收集的信息,我需要创建一个调用 wine 的 AppleScript,但是如何获取 AppleScript 中输入文件的名称?如果有更好的方法可以做到这一点,请告诉我,但据我所知这是最好的方法。
I want to associate the .exe file extension with a shell script that launches wine. What is the best way to do this?
From what I've gathered, I need to create an AppleScript that will call wine, but how do I get the name of the input file in the AppleScript? If there is a better way to do this, let me know, but as far as I know this is the best way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还可以使用 Automator 将您自己的 bash、python 或 ruby 脚本包装在“应用程序”中。
打开 Automator 并选择创建应用程序。
找到“运行 Shell 脚本”操作,然后双击或将其拖至脚本区域。
选择您想要的解释器(bash、其他 shell、python 或 ruby)。
将“传递输入”选项设置为“作为参数”。 (在自动化模型中,应用程序“接收文件和文件夹作为输入”;因此,这可以让您的脚本将文件名视为命令行参数)。
在编辑区域中输入您的 shell 脚本。在 bash 上,使用“$@”作为命令行参数列表(单独引用以保护嵌入空格)。
您现在可以保存脚本(它将获得
.app
扩展名),并将其移动到“应用程序”文件夹或其他合理的位置。与任何其他应用程序一样,它可以与文件类型关联。注意:这适用于 Mountain Lion (10.8);有人可以评论一下 Automator 能够做到这一点多久了吗?
You can also use Automator to wrap your own bash, python or ruby script in an "Application".
Open Automator and choose to create an Application.
Find the Action "Run Shell Script" and double-click it or drag it to the script area.
Select the interpreter you want (bash, other shells, python or ruby).
Set the "Pass input" option to "as arguments". (In the automator model, the application "receives files and folders as input"; hence this lets your script see filenames as commandline arguments).
Enter your shell script in the edit area. On bash, use "$@" for the list of commandline arguments (individually quoted to protect embedded spaces).
You can now save the script (it will get a
.app
extension), and move it to the Applications folder or other reasonable location. It can be associated with a file type, like any other application.NOTE: This works on Mountain Lion (10.8); can someone comment on how long Automator has been able to do this?
您可以使用 AppleScript 应用程序来执行此操作 - 文件被传递到 open 处理程序,与 Droplet 相同,例如:
要将特定文档类型与您的应用程序关联,您首先需要添加信息添加到应用程序的信息属性列表 (Info.plist) 中,以告知启动服务它可以处理哪些类型的文档。请参阅 Apple 的 基于文档的应用程序概述(或查看其他应用程序中的设置)。
You can use an AppleScript application to do this - files are passed to the open handler, the same as a droplet, for example:
To associate a particular document type with your application, you will first need to add information to your application's information property list (Info.plist) to tell Launch Services what types of documents it can handle. See Apple's Document-Based Applications Overview (or take a look at the settings in other applications).