简体   繁体   English

在终端的新选项卡中运行命令

[英]Run a command in a new tab in terminal

I'm trying to write a script that could run several commands in several tabs in the terminal. 我正在尝试编写一个可以在终端的多个选项卡中运行多个命令的脚本。 I found a lot of informations about it, but it doesn't work as I want it to. 我发现了很多关于它的信息,但它并不像我想要的那样工作。 So I probably need AppleScript. 所以我可能需要AppleScript。

• This code run a command in a new window: •此代码在新窗口中运行命令:

tell app "Terminal"
   do script "echo hello"
end tell

• And this one open a new tab •这一个打开一个新选项卡

tell application "Terminal"
  activate
  tell application "System Events"
    keystroke "t" using {command down}
  end tell
end tell

But I didn't figured out how to "mix" them. 但我没想出如何“混合”它们。 Any idea ? 任何的想法 ?

tell application "Terminal"
    activate
    tell application "System Events"
        keystroke "t" using {command down}
    end tell
    do script "echo hello" in selected tab of the front window
end tell

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 运行执行一个命令的终端脚本,并在该命令运行时打开一个新选项卡并运行另一个命令 - run Terminal script that executes one command and while that command is running, opens a new tab and runs another command 在osx上,如何从一个脚本打开新的iterm终端选项卡,然后在该临时窗口中运行命令 - On osx, how to open new iterm terminal tab from one script then run command in that temrinal window 如何打开一个新终端并在新终端中运行命令? - How to open a new terminal and run command in new terminal? 如何使用python打开新终端并在新终端中运行命令 - How to open new terminal and run command in the new terminal using python 从命令行打开新的终端选项卡 (Mac OS X) - Open new Terminal Tab from command line (Mac OS X) 在 macOS 上,如何从终端打开新的 Chrome window 而不是新标签(即 Bash 命令) - On macOS, how to open a new Chrome window instead of a new tab from terminal (i.e., Bash command) 如何在选项卡中打开新的 z shell 并运行命令? - How can I open a new z shell in a tab and run a command? Apple Script创建一个新标签来运行bash命令 - Apple Script to create a new tab to run a bash command 在OSX中,我可以使用系统调用将命令传递给新选项卡中的正在运行的终端吗? - In OSX can I use a system call to pass a command to a running terminal in a new tab? 通过xCode运行终端和命令 - Run terminal and command through xCode
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM