终端准备/完成时的通知 - Applescript

Tim*_*imm 7 macos terminal notifications applescript

有没有办法在终端完成命令时收到通知?

- >我运行另一个脚本(不是我的!),当这个脚本完成时下载数据我想退出终端并用这些数据做其他事情.

编辑:
我可能没有正确地问...

例:


tell application "Terminal"
   keystroke "php downloadscript.php"
   keystroke return
end tell

if (downloadFinished) -- do stuff else -- wait till finished

编辑2: 太棒了!谢谢!这样工作:


tell application "Terminal"
    set frontWindow to window 1
    repeat until busy of frontWindow is false
        delay 1
    end repeat
    #display dialog "finished"
end tell
问候hatschii

Lri*_*Lri 6

当标签打印\ a且标签未聚焦或终端不在最前面时,终端的Dock图标开始弹跳:

sleep 5; printf '\a'
Run Code Online (Sandbox Code Playgroud)

你也可以运行类似的东西afplay /System/Library/Sounds/Blow.aiff.或使用terminal-notifier:

sudo gem install terminal-notifier
terminal-notifier -message ''
Run Code Online (Sandbox Code Playgroud)

您可以通过检查选项卡的busy属性来等待程序运行完毕:

tell application "Terminal"
    set w to do script "sleep 5"
    repeat
        delay 1
        if not busy of w then exit repeat
    end repeat
end tell
Run Code Online (Sandbox Code Playgroud)