def main()

in cortado/rtas/iterm2_autolaunch.py [0:0]


def main():
    iterm2 = "/Applications/iTerm.app/Contents/MacOS/iTerm2"
    backup_iterm2 = "/tmp/backup_iterm2"
    masquerade_bash = "/tmp/bash"
    path = Path(iterm2)
    restore_backup = False

    if path.is_file():
        restore_backup = True
        _common.copy_file(iterm2, backup_iterm2)

    _common.create_macos_masquerade(iterm2)
    _common.create_macos_masquerade(masquerade_bash)

    # Execute command
    log.info("Spawning bash from fake iterm2 commands")
    command = f"{masquerade_bash} /Users/test/.config/iterm2/AppSupport/Scripts/test"
    _ = _common.execute_command([iterm2, "childprocess", command], timeout_secs=10)

    # reset iterm2 and cleanup
    if restore_backup:
        _common.copy_file(backup_iterm2, iterm2)

    _common.remove_file(backup_iterm2)
    _common.remove_file(masquerade_bash)