In OSX, can I use a system call to send a command to a running terminal in a new tab?

In particular,

In OSX 10.6, from a system call, I want to open a file for editing with VIM in an existing terminal (i.e. Terminal.app) by opening a new tab.

Of course I can open a new instance of the terminal

/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -e vim MyFile

And, of course, I can calculate the PID of a working instance of the terminal, but I don’t know how to pass the command to this running program. Or, if the terminal supports receive commands and opens a new tab.

If someone knows how to do this with a similar system (like linux and xterm), can this help me deal with OSX and Terminal - or is there any other way to prevent opening so many terminal instances?

EDIT: CHEAP SOLUTION

I created an AppleAcript script

on run app_arg
    tell application "System Events"
        tell application process "Terminal"
            key code {55, 36}
            set frontmost to true
            key code {55, 17}
            keystroke item 1 of app_arg
            keystroke return
        end tell
    end tell
end run

/usr/bin/osascript NEWSCRIPT.scpt "args"

, - !

+3
2

applescript. applescript OS X osascript. - , , , , Terminal.app applescript, .

, , - applescript Command-T . , . , .: -)

+2
-2

Source: https://habr.com/ru/post/1730571/


All Articles