Skip to content

Instantly share code, notes, and snippets.

@gnachman
Created August 19, 2020 06:40
Show Gist options
  • Save gnachman/7785295d72b29472e5b59ccc0f3b2b27 to your computer and use it in GitHub Desktop.
Save gnachman/7785295d72b29472e5b59ccc0f3b2b27 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3.7
import iterm2
async def main(connection):
   app = await iterm2.async_get_app(connection)
   session = app.current_terminal_window.current_tab.current_session
   async with session.get_screen_streamer(want_contents=True) as streamer:
       while True:
           content = await streamer.async_get()
           for i in range(content.number_of_lines):
               line = content.line(i)
               print(line.string)
iterm2.run_until_complete(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment