Applescript to quit Terminal

我是研究僧i 提交于 2020-01-25 00:22:26

问题


Background: I’m a Mac user, who maintains a program in PostScript. Postscript is interpreted (‘distilled’) by Adobe Distiller. So sometimes I want a second or third session of Adobe Distiller.

To open such an instance I have a small text file named ‘DistillerNewInstance.command’:

open -n -a "Acrobat Distiller"
osascript -e 'tell application "Terminal" to close first window'
osascript -e 'tell application "Terminal" toquit saving no'

The Distiller bit works perfectlly. Happiness.

But Terminal doesn’t quit. It asks “Do you want to terminate running processes in this window?”. Some variations of the above close the window but leave Terminal running. Please, what can go in my .command file that will make Terminal quietly go away? (Without unsafe usage of killall.)

Thank you.


回答1:


Consider executing the open shell command directly via AppleScript using its do shell script command instead of via the Terminal application.

By utilizing the following AppleScript it will negate the need to close any Terminal windows and quit it.

repeat 3 times
  do shell script "open -n -a" & space & quoted form of "Acrobat Distiller"
end repeat

The example given above will launch three instances of the Acrobat Distiller application.



来源:https://stackoverflow.com/questions/58578550/applescript-to-quit-terminal

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!