我已经在互联网上找到了applescript代码,用于启动终端并启动Elasticsearch代码是
tell app "Terminal"
do script "elasticsearch-5.5.0/bin/./elasticsearch"
end tell
效果很好,现在我想在上面添加更多内容,我需要再打开4个新选项卡not new window仅选项卡(command + T)。然后运行不同的命令(例如log tail命令),在每个选项卡中依次启动kibana。
我是applescript的新手,但通过搜索示例和教程感到厌倦,任何人都可以提出解决方案或您的想法来实现自动化。
假设您使用的是Mac,应用程序Automator在您的情况下可能会非常有帮助。 Automator非常通用。您可以开始使用here。
终端的脚本字典不是很多'Apple Event Handler Failed'错误-但您可以使用以下代码来管理它:
tell application "Terminal" to activate
my makeTab("ls -al")
my makeTab("top")
my makeTab("cd ~/Documents")
on makeTab(cmd)
tell application "System Events" to keystroke "t" using {command down}
tell application "Terminal"
do script cmd in last tab of front window
end tell
delay 0.2
end makeTab
只需将要运行的任何命令放在makeTab()
调用中。