fabiospampinato / vscode-terminals

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

Enable relative cwd #15

Closed brian-mann closed 5 years ago

brian-mann commented 5 years ago

We're trying to use our .vscode terminals config across team members. For this to work, cwd needs to be able relative. Can we add path.resolve() support so users can pass either a relative or absolute path for cwd?

// terminals.json
{
  "terminals": [
    {
      "cwd": "./packages/server",
    }
  ]
}

Alternatively the user of VS code variables would also suffix per this: https://code.visualstudio.com/docs/editor/variables-reference

I get that you allow your own variable substitutions, but this is only for the command not other properties.

fabiospampinato commented 5 years ago

I'll add variable substitution support for the other fields as well.

Relative paths might be a nice addition too.

fabiospampinato commented 5 years ago

Implemented.

You can solve your problem in at least 3 ways:

  1. Add a cd ./my_path command to your commands list
  2. Use a relative path in cwd: "cwd": "./my_path"
  3. Use variable substitution in cwd: "cwd": "[workspaceFolder]/my_path"

While a was at it I've also added support for paths that start with a tilde, so that if for some reason you guys need this you can now do: "cwd": "~/other_project".

brian-mann commented 5 years ago

Great thank you, all this will work.

The reason prepending commands with cd ./path isn't ideal is because VSCode linkify's paths always relative to the cwd that the terminal was originally spawned with. In our case we have a monorepo hence the nested packages.

This means cd'ing into a subfolder and then running npm commands relative to that new path results in them not being clickable links. This is one of the primary reason I'm using this extension. With relative path support, now we can share the .vscode settings across the whole team.