Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment property to the profiles in settings.json #6604

Closed
intractabilis opened this issue Jun 20, 2020 · 10 comments
Closed

Add environment property to the profiles in settings.json #6604

intractabilis opened this issue Jun 20, 2020 · 10 comments
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.

Comments

@intractabilis
Copy link

Following @DHowett suggestion in #6585.

Description of the new feature/enhancement

For tools like MinGW you need certain environment variables to be set that define their behavior. It would be convenient to have these settings in the profile.

I suggest to add a property to the profile description in settings.json to set environment variables. For example

{
    "environment" : {
        "PATH": "c:/doomsday/emergency_commands/bin;${env:PATH}",
        "EMRGENCY_LEVEL_HIGH": "1"
    }
}
@intractabilis intractabilis added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jun 20, 2020
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 20, 2020
@zadjii-msft
Copy link
Member

Yep, this seems like a good and reasonable feature request. We'll need to make sure that the ${env:PATH} syntax is well-defined. I think we're already doing some sort of env var string replacing, so we could probably just re-use that.

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Product-Terminal The new Windows Terminal. labels Jun 23, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 23, 2020
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jun 23, 2020
@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jun 25, 2020
@mle-ii
Copy link

mle-ii commented Aug 14, 2020

Glad to see this here... I just started using Windows Terminal and love it, and this was one item I was searching for in the docs on how to do. I would love to be able to set PATH here and not have to override it for all other consoles.

That said I could probably work around this by setting up a batch file to run when a console opens up. At least in my head this might be possible as I've used this for other things where I initialized the command line environment for specific tools.

@CaiB
Copy link

CaiB commented Oct 1, 2020

I got around this by making a .cmd file containing:

@echo off
cls
SET PATH=whatever
ssh me@myserver

(Just replace the ssh line with what you wanted to run)

And then in the config.json in the profile I have:

"commandline": "cmd /s /c C:/Path/To/MyFile.cmd"

@KalleOlaviNiemitalo
Copy link

Would "var": "" remove the environment variable or add it with an empty value? If the latter, then "var": null could remove the variable.

@rivy
Copy link

rivy commented Oct 1, 2020

If your needs are relatively simple, a commandline statement using cmd and a compound statement is a solution which works now, eg:

"commandline": "cmd.exe /k \"set ENV_VAR=foo && set PATH=%PATH%;bar/baz\"",

@KalleOlaviNiemitalo
Copy link

#2785 seems to ask for the same thing, except it does not mention any ${env:PATH} or equivalent syntax.

@dolpsdw
Copy link

dolpsdw commented Nov 17, 2020

Terraform Example with Windows Terminal Variables
powershell
"commandline": "powershell.exe -NoExit $env:ENV_VAR='foo'; $env:Path += ';C:\\PORT\\terraform014;C:\\PORT\\apache-maven-3.6.3\\bin' ",

cmd
"commandline": "cmd.exe /k \"set ENV_VAR=foo && set PATH=%PATH%;C:\\PORT\\terraform014;C:\\PORT\\apache-maven-3.6.3\\bin\"",

@KalleOlaviNiemitalo
Copy link

If you have

{
    "environment" : {
        "HOMEDRIVE": "C:",
        "HOME": "${env:HOMEDRIVE}${env:HOMEPATH}",
        "HOMEPATH": "\\Users\\example"
    }
}

then should HOME use the original or new value of HOMEPATH? Should that depend on the lexical order of properties in the JSON object?

It might be easiest to implement this so that ${env:VAR} always means the original value, and the lexical order does not matter. If it becomes possible to define environment variables both globally and in each profile, then ${env:VAR} in a profile could refer to the value defined in the global environment object, and ${env:VAR} in the global environment could refer to the value received from Windows.

The syntax leaves room for adding ${new-env:VAR} with topological sorting later if needed.

@zadjii-msft
Copy link
Member

Oh my goodness, this is a dupe of #2785, isn't it. I'll move some of the relevant discussion over to that thread. Thanks for the help triaging @KalleOlaviNiemitalo!

/dup #2785

@ghost
Copy link

ghost commented Nov 23, 2020

Hi! We've identified this issue as a duplicate of another one that already exists on this Issue Tracker. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report!

@ghost ghost closed this as completed Nov 23, 2020
@zadjii-msft zadjii-msft removed this from the Terminal Backlog milestone Nov 23, 2020
@ghost ghost added Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing. Needs-Tag-Fix Doesn't match tag requirements labels Nov 23, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Help Wanted We encourage anyone to jump in on these. Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal. Resolution-Duplicate There's another issue on the tracker that's pretty much the same thing.
Projects
None yet
Development

No branches or pull requests

8 participants