#!/usr/bin/env python3
import subprocess
import json

def main():
    output = subprocess.check_output(["kitty", "@", "ls"])
    data = json.loads(output)
    for window in data:
        print(f"Window: {window['id']}")
        for tab in window["tabs"]:
            print(f"\tTab: {tab['id']}: {tab['title']}")
            for pane in tab["windows"]:
                print(f"\t\t{pane['id']}: {pane['cmdline']}")
    tabid = input("Choose tab: ")
    subprocess.run(["kitty", "@", "send-text", "--match-tab", f"id:{tabid}", "--stdin"])

if __name__ == "__main__":
    main()
    pass
