The script takes the host addresses as arguments, and opens the split panel and connects to each host.
Created
June 2, 2021 15:55
-
-
Save f4rx/c0cbc0e6157cca351ddb312b05ac2cfa to your computer and use it in GitHub Desktop.
iterm2-ssh-multiple-hosts-in-splitting-panes.py
This file contains hidden or 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 | |
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