0

我有一个用于服务的 Automator 脚本,如下所示:

Receives as text in any application. Input is entire selection, does not replace selected text.
-> Run Shell Script (/bin/bash) "expand -t 4" pass input to stdin
-> Copy to Clipboard

没有设置其他选项。这个想法是我可以选择一些代码,然后在剪贴板中放置一个去标签的版本,而不必将代码粘贴到 BBEdit 中进行去标签。

该服务仅生成所选文本的第一行。删除 shell-script 操作会将所有选定的文本放到剪贴板上。跑步

expand -t 4 < /path/to/tabbed.file > result.file

产生整个输入文件的转换内容。将命令替换为“wc”可以显示合理的行数、单词数和字符数。

因此,问题似乎在于通过来自 Automator 服务输入的标准输入将多于一行的选择传递给 expand(1)。我没有从 expand(1) 手册页中看到任何相关内容。

我究竟做错了什么?

4

1 回答 1

0

试试这个 AppleScript:

on run {input}
    set the clipboard to (do shell script "expand -t 4 <<< " & quoted form of (input as text))
end run
于 2013-02-05T17:39:42.240 回答