Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

• 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 ?

like image 863
Cohars Avatar asked Feb 04 '14 14:02

Cohars


1 Answers

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
like image 191
Gordon Davisson Avatar answered Oct 07 '22 13:10

Gordon Davisson