Skip to content

Instantly share code, notes, and snippets.

@f4rx
Created June 2, 2021 15:55
Show Gist options
  • Save f4rx/c0cbc0e6157cca351ddb312b05ac2cfa to your computer and use it in GitHub Desktop.
Save f4rx/c0cbc0e6157cca351ddb312b05ac2cfa to your computer and use it in GitHub Desktop.
iterm2-ssh-multiple-hosts-in-splitting-panes.py
#!/usr/bin/env python3
import sys
import iterm2
async def main(connection):
app = await iterm2.async_get_app(connection)
main_session = app.current_terminal_window.current_tab.current_session
profile = await main_session.async_get_profile()
if len(sys.argv) > 2:
for host in reversed(sys.argv[2:]):
right_session = await main_session.async_split_pane(
vertical=True,
profile=profile.name,
)
await right_session.async_send_text(f"ssh {host} \n")
if len(sys.argv) > 1:
await main_session.async_send_text(f"ssh {sys.argv[1]} \n")
await main_session.async_activate()
iterm2.run_until_complete(main)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment