Osascript to Bash Command



这很简单。就是做不好。

我正在制作一个alfredworkflow,在这里我想要一个URL,然后curl/wget(程序无关紧要)在终端。如果我能在后台这样做,那就太好了,但如果它需要打开终端,我可以接受。

到目前为止我有什么:

tell application "Google Chrome"
  set theURL to URL of active tab of window 1
end tell
tell application "Terminal"
    activate
    do script "echo "${theURL}
end tell 

试试这个:

tell application "Google Chrome"
    set theURL to URL of active tab of window 1
end tell
do shell script "curl --remote-name '" & theURL & "'"

AppleScript中的字符串连接操作符是&,你不能把${...}放在变量周围。

这将在后台运行curl,不需要打开终端。--remote-name选项告诉它将结果写入一个文件名类似URL的文件名部分的文件。

最新更新