0
我正在从AppleScript执行bash命令,但脚本非常难看,而且我只对在终端中看到输出感兴趣。在终端中隐藏bash输入
例子:
tell application "Terminal"
do script "pwd"
end tell
终端(我想隐藏PWD):
pwd
/Users/jdoe
我正在从AppleScript执行bash命令,但脚本非常难看,而且我只对在终端中看到输出感兴趣。在终端中隐藏bash输入
例子:
tell application "Terminal"
do script "pwd"
end tell
终端(我想隐藏PWD):
pwd
/Users/jdoe
如果使用clear
(或tput clear
或printf \\ec
),如果你向上滚动旧内容显示
tell application "Terminal"
do script " osascript -e 'tell app \"system events\" to keystroke \"k\" using command down'; pwd"
activate
end tell
的命令是do shell script "pwd"
,才只显示输出,当我在脚本编辑器或通过跑了osascript test.scpt
在终端中。
tell application "Terminal"
do script " clear; pwd"
activate
end tell
这可以有一个明显的延迟,如果系统事件不运行::
我已经更新了示例,而不是“pwd”,有一个交互式脚本和“do script”通过终端执行它。 – Scientist1642
为什么你要去启动一个终端而不是简单地运行'do shell script'呢? –
因为我想要一个用户在终端上与它进行交互,shell脚本会在后台执行它。 – Scientist1642