OSX 将 shell 脚本与文件扩展名关联? [英] OSX Associate a shell script with a file extension?

查看:34
本文介绍了OSX 将 shell 脚本与文件扩展名关联?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 .exe 文件扩展名与启动 wine 的 shell 脚本相关联.做这个的最好方式是什么?

I want to associate the .exe file extension with a shell script that launches wine. What is the best way to do this?

从我收集到的信息来看,我需要创建一个名为 wine 的 AppleScript,但是如何在 AppleScript 中获取输入文件的名称?如果有更好的方法来做到这一点,请告诉我,但据我所知,这是最好的方法.

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.

推荐答案

您可以使用 AppleScript 应用程序来执行此操作 - 文件将传递给 open 处理程序,例如与 droplet 相同:

You can use an AppleScript application to do this - files are passed to the open handler, the same as a droplet, for example:

on open theFiles
    set arguments to ""
    repeat with anItem in theFiles
        set arguments to arguments & space & (quoted form of POSIX path of anItem)
    end repeat
    do shell script "/path/to/wine" & arguments
end open

要将特定文档类型与您的应用程序相关联,您首先需要将信息添加到应用程序的信息属性列表 (Info.plist) 中,以告诉 Launch Services 它可以处理哪些类型的文档.请参阅 Apple 的 基于文档的应用程序概述(或查看其他应用程序中的设置).

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).

这篇关于OSX 将 shell 脚本与文件扩展名关联?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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