Skip to content

Instantly share code, notes, and snippets.

@gnachman
Created August 19, 2020 06:39
Show Gist options
  • Save gnachman/1bdd2d8aea0f587f8197fffd1a131de5 to your computer and use it in GitHub Desktop.
Save gnachman/1bdd2d8aea0f587f8197fffd1a131de5 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
   contents = await session.async_get_screen_contents()
   for i in range(contents.number_of_lines):
       line = contents.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