PowerShell / ProjectMercury

An interactive shell to work with AI-powered assistance providers
MIT License
32 stars 5 forks source link

Support iTerm2 for `Start-AISH` #147

Closed StevenBucher98 closed 1 month ago

StevenBucher98 commented 1 month ago

Ideally the user flow is Start-Copilot -Path <path> will be able to detect itself what platform it is on, mac or windows. If its on a Mac, check if it is being run via iTerm2 and then split the pane and open up aish. If the user is running Start-AISH in any other terminal besides iTerm2 or Windows Terminal, we should open up a new window with aish running.

Below is a python script to get the split pane experience:

import iterm2

#iTerm needs to be running for this to work
async def main(connection):
    app = await iterm2.async_get_app(connection)

    # Foreground the app
    await app.async_activate()

    window = app.current_terminal_window
    if window is not None:
        # Get the current pane so that we can split it 
        currentpane = app.current_terminal_window.current_tab.current_session
        # Split pane vertically
        splitpane = await currentpane.async_split_pane(vertical=True)
        await splitpane.async_send_text('<path to aish>\n')

    else:
        # You can view this message in the script console.
        print("No current window")

# Passing True for the second parameter means keep trying to
# connect until the app launches.
iterm2.run_until_complete(main, True)

Things to check