It's quite easy to send a command using the API:
#!/usr/bin/env python3
import tkinter as tk
import iterm2
# To install, update, or remove packages from PyPI, use Scripts > Manage > Manage Dependencies...
async def main(connection):
# Your code goes here. Here's a bit of example code that adds a tab to the current window:
app = await iterm2.async_get_app(connection)
session = app.current_window.current_tab.current_session
if session is not None:
await session.async_send_text('date\n')
But how to capture the result of this command? I've checked:
ScreenStreamer
async_get_contents
(see API doc)
But nothing is really working for me. Any thoughts?