【发布时间】:2019-01-29 02:09:01
【问题描述】:
我正在尝试创建一个上下文菜单快捷方式,以便在 VS Code 中从原始项目或其别名打开文件/文件夹
到目前为止,我已经能够创建一个 Automator 服务,它:
- 已选择接收:文件或文件夹
- 在:任何应用程序运行
- shell 脚本:
open -n -b "com.microsoft.VSCode" --args "$*"
如何将其更改为也接受别名?
【问题讨论】:
标签: applescript automator
我正在尝试创建一个上下文菜单快捷方式,以便在 VS Code 中从原始项目或其别名打开文件/文件夹
到目前为止,我已经能够创建一个 Automator 服务,它:
open -n -b "com.microsoft.VSCode" --args "$*"
如何将其更改为也接受别名?
【问题讨论】:
标签: applescript automator
符号链接应该没问题,但是 Finder 别名通常不起作用,因为大多数 shell 实用程序将它们视为小数据文件并且不知道如何解释它们。一种解决方案是添加 Run AppleScript 操作以在输入中查找别名并改用原始项目,例如:
运行 AppleScript:
on run {input, parameters}
set output to {} -- this will be a list of the output items
tell application "Finder" to repeat with anItem in the input
if anItem's kind is "Alias" then
set the end of output to POSIX path of (original item of anItem as alias)
else
set the end of output to POSIX path of anItem
end if
end repeat
return output
end run
【讨论】: