Skip to content

Instantly share code, notes, and snippets.

@libbyschuknight
Created June 25, 2020 08:26
Show Gist options
  • Save libbyschuknight/bad64b78d98d44e51c0e90b14a54f2f9 to your computer and use it in GitHub Desktop.
Save libbyschuknight/bad64b78d98d44e51c0e90b14a54f2f9 to your computer and use it in GitHub Desktop.
simple script for opening a new tab and running a command
#!/usr/bin/env python3.7
import iterm2
# This script was created with the "basic" environment which does not support adding dependencies
# with pip.
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)
window = app.current_terminal_window
if window is not None:
tab = await window.async_create_tab()
await tab.current_session.async_send_text("echo 'hello'\n")
else:
# You can view this message in the script console.
print("No current window")
iterm2.run_until_complete(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment