macos - 执行后退出终端

标签 macos shell terminal applescript

我有一个运行AppleScript的Shell脚本。该applescript是从终端执行的,我希望该终端在完成后关闭。

在我的shell脚本中,我用这一行执行applescript。它会打开一个终端,运行,然后即使该AppleScript完成,该终端也只是坐在那里。我打开了所有我一直使用的终端,所以我不想只关闭一个终端。

 osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript"'


谢谢

最佳答案

在您的Shell脚本中,您执行

osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript"'


什么才真正打开一个新的Terminal.app窗口。

您是否出于某些特殊原因需要打开新的终端窗口?为什么不运行

osascript ~/Scripts/reset_simulator.applescript


从您的Shell脚本中并在当前窗口中。

但是,如果您想要这样的东西(听起来很奇怪),总是可以使用下一个:

osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript;exit"'
#note the "exit" here ---------------------------------------------------------------------------------^^^^^


退出后,将“首选项”更改为“关闭窗口”。

在上面阅读您的评论,听起来比您想在“背景”中运行一些applescript听起来要好得多。

因此,您可以执行以下操作:

a。)从您的shell脚本

osascript ~/Scripts/reset_simulator.applescript &


2.)如果您仍要打开另一个终端窗口

osascript -e 'Tell application "Terminal" to do script "osascript ~/Scripts/reset_simulator.applescript&exit"'
#note the & here --------------------------------------------------------------------------------------^

关于macos - 执行后退出终端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25773238/

相关文章:

macos - Golang x509 无法在 Mac OS X 上加载系统根错误

python - 如何在 python 中一致地从串行打印数据

linux - 进入chroot,发出命令,停留在chroot

swift + OS X 沙盒:将 'NSVBOpenPanel' 视为 'NSOpenPanel'::因为我需要在委托(delegate)方法中获取发件人

c++ - 如何在 OS X 中检查用户名/密码组合?

unix - 目录的递归列表

linux - 如何使用 bash 将未加引号的地址包装在文件中?

linux - Bash_profile 文件编辑

linux - sudo alsactl store 不保存捕获设置

bash - 如何将参数传递给 shell 脚本中定义的函数?