fabiospampinato / vscode-terminals

An extension for setting-up multiple terminals at once, or just running some commands.
MIT License
121 stars 20 forks source link

Autoswitch terminal based on open file path #23

Open ProLoser opened 5 years ago

ProLoser commented 5 years ago

Background

I have a monorepo or a multi-root workspace. I launch multiple terminals, some associated with specific folder trees (specific packages in my monorepo or a specific project-root). I frequently switch between projects and the current UI for switching associated terminals is tedious.

Proposal

I'd like to add an optional glob pattern match to some of my terminal configurations. When a file or folder is opened, I'd like the active terminal to switch (if already started) to the corresponding terminal. Switching visible terminal should only occur if the terminal panel is already open.

This would mirror the Source Control panel's UX where selecting files or root folders changes what GIT repo you're currently working with.

[
    {
        "name": "myLibrary",
        "icon": "play",
        "command": "yarn workspace myLibrary start",
        "open": true,
        "autoswitch": "**/myLibrary/**"
    },
    {
        "name": "project-a",
        "icon": "repo-clone",
        "command": "yarn workspace project-a start",
        "open": true,
        "autoswitch": "**/project-a/**"
    },
    {
        "name": "project-b",
        "icon": "screen-full",
        "command": "yarn workspace project-b test",
        "open": true
    }
]

P.S. I LOVE this project, might try to patch vscode to get the split terminal API because I'd love that feature too.

fabiospampinato commented 5 years ago

Our config object is getting pretty complicated, but I like your proposal. The only problem is that I think there's no API for detecting the status of the bottom pane (visible/hidden) 🤔

ctf0 commented 5 years ago

@fabiospampinato you can get pretty much all the api stats for vscode by using Developer: Inspect Context Keys and check the console.