This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3.7 | |
# Import iterm2 library | |
import iterm2 | |
async def main(connection): | |
# Get current window | |
app = await iterm2.async_get_app(connection) | |
window = app.current_terminal_window | |
if window is not None: | |
# Create new tab, get session and print text | |
tab = await window.async_create_tab() | |
session = tab.current_session | |
# \n is crucial as it simulates Enter. | |
await session.async_send_text('echo "hello world from main pane"\n') | |
# Create new pane on the right and print text | |
pane2 = await session.async_split_pane(vertical=True) | |
await pane2.async_send_text('echo "hello world from pane 1"\n') | |
# Create new pane at the bottom of pane2 and print text | |
pane3 = await pane2.async_split_pane(vertical=False) | |
await pane3.async_send_text('echo "hello world from pane 2"\n') | |
# Create new pane at the bottom of main pane (session) and print text | |
pane4 = await session.async_split_pane(vertical=False) | |
await pane4.async_send_text('echo "hello world from pane 3"\n') | |
else: | |
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