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

(Feature Request) Terminal Environment setting (like in VScode) #2785

Closed
Merith-TK opened this issue Sep 17, 2019 · 21 comments · Fixed by #15082
Closed

(Feature Request) Terminal Environment setting (like in VScode) #2785

Merith-TK opened this issue Sep 17, 2019 · 21 comments · Fixed by #15082
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalConnection Issues pertaining to the terminal<->backend connection interface Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR 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.
Milestone

Comments

@Merith-TK
Copy link

Merith-TK commented Sep 17, 2019

Description of the new feature/enhancement

Arguments to the program. for example the ability to specify which mingw one would want to load, mingw64, mingw32, or msys2. like we can in VSCode

Proposed technical implementation details (optional)

This is accomplished in VSCode via this directive in settings.json

    "terminal.integrated.env.windows":
    {
        "MSYSTEM": "MINGW64",
        "CHERE_INVOKING":"1"
    },

My thougt process allowed something like

"commandlineEnv" : 
{
    "MSYSTEM" : "MINGW64"
},

In the settins.json file example. just like VSCode

Please do note, i know little to nothing about this language that this program is written in, so i don't know how difficult it would be to implement.

@Merith-TK Merith-TK added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Sep 17, 2019
@ghost ghost added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 17, 2019
@zadjii-msft
Copy link
Member

This is actually won't be terribly difficult to implement IMO. In ConhostConnection, we're already creating a EnvironmentVariableMapW with a WT_SESSION env var.

It wouldn't be impossible to also have another map of string->string key-value pairs that we also pass to the connection like this.

@zadjii-msft zadjii-msft added Area-Settings Issues related to settings and customizability, for console or terminal Product-Terminal The new Windows Terminal. labels Sep 17, 2019
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Sep 17, 2019
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Sep 17, 2019
@zadjii-msft zadjii-msft added the Help Wanted We encourage anyone to jump in on these. label Sep 17, 2019
@Merith-TK
Copy link
Author

Right now my current workaround is to use this .cmd file and ahve the terminal run that

set "MSYSTEM=MINGW64" 
C:/msys/usr/bin/bash.exe --login -i

@DHowett-MSFT DHowett-MSFT added Area-TerminalConnection Issues pertaining to the terminal<->backend connection interface and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Sep 19, 2019
@Merith-TK
Copy link
Author

any progress? or is this put in the background with priority on bug fixes/better features? If so, i would understand.

@DHowett-MSFT
Copy link
Contributor

Right now, we're focusing on bug fixes and features. You can check out our plans for October in the Terminal-1910 milestone, if you're interested. Right now, this one's sitting on the backlog ("not v1.0, but if we get some spare time we'll look at the features we've put off.")

That's not to say we don't care about this, of course. We'd be more than happy to review a pull request that adds support for this, so we've marked it Help-Wanted.

@DHowett-MSFT
Copy link
Contributor

Thanks for asking!

@Merith-TK
Copy link
Author

Ah! no worries! Sadly I know NOTHING about the lang this is being written in, so I cant be of any help here! I totally understand that! Functionality over features! Make the Program work, and THEN you add cool features (if that makes any sense)

@zadjii-msft
Copy link
Member

Moving relevant discussion from #6604:

#6604

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"
    }
}

#6604 (comment)

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.

@UndarkAido
Copy link

UndarkAido commented Jan 15, 2021

Is there any workaround for this? I'm trying to set up an SSH session with X forwarding. The environment variables get set weirdly when I do "commandline": "cmd /c \"set TMPDIR=C:\\Temp && set XAuthLocation=C:\\Progra~1\\VcXsrv\\xauth.exe && set DISPLAY=localhost:0 && ssh -X aidan@172.28.0.1\""

Edit: Remove the spaces before the &&s:
"commandline": "cmd /c \"set TMPDIR=C:\\Temp&& set XAuthLocation=C:\\Progra~1\\VcXsrv\\xauth.exe&& set DISPLAY=localhost:0&& ssh -X aidan@172.28.0.1\""

christapley added a commit to christapley/terminal that referenced this issue Feb 8, 2021
christapley added a commit to christapley/terminal that referenced this issue Feb 8, 2021
* use StringMap as a container
@christapley
Copy link
Contributor

Hello @zadjii-msft, I would like to implement this feature. I'm still getting up to speed with your processes. Do you have any documentation on how you run your tests (specifically LocalTests_SettingsModel)?

@zadjii-msft
Copy link
Member

zadjii-msft commented Feb 9, 2021

That is a good question! I'm fairly certain that everyone on the team has a slightly different process but here's how I do it:

  1. Open a new cmd.exe tab/pane
  2. navigate to the directory the repo is in
  3. run tools\razzle.cmd
  4. then navigate to wherever the project you want to build is (in this case, cd src\cascadia\LocalTests_SettingsModel)
  5. bx to build the project in this dicrectory
  6. Then I use runut /name:*TestNameHere* to run the tests. The /name: arg lets you select tests to run based off the fully-qualified name. So if you wanted to run all the local tests for TSM, you could run runut /name:*SettingsModelLocalTests*. Or you could run a specific test with something like runut /name:*CanLayerColorScheme*. It's fairly flexible.

You only need to do steps 1-3 once. Once you have the "razzle" window set up, you can just keep switching to new directories and building them, you don't need to start a new window each time.

Lemme know if you need any other help. All the "Local" tests are a little weird, so I wouldn't be surprised if you ran into other issues ☺️

@christapley
Copy link
Contributor

Thank you @zadjii-msft, I got the tests running.

christapley added a commit to christapley/terminal that referenced this issue Feb 10, 2021
christapley added a commit to christapley/terminal that referenced this issue Feb 11, 2021
christapley added a commit to christapley/terminal that referenced this issue Feb 11, 2021
* use StringMap as a container
* recursively resolve ${env:NAME} vars in values in the StringMap or in
  the process' environment
* implement some tests
@ghost ghost added the In-PR This issue has a related PR label Feb 11, 2021
christapley added a commit to christapley/terminal that referenced this issue Feb 25, 2021
* use StringMap as a container
* recursively resolve ${env:NAME} vars in values in the StringMap or in
  the process' environment
* implement some tests
christapley added a commit to christapley/terminal that referenced this issue Feb 25, 2021
* use StringMap as a container
* recursively resolve ${env:NAME} vars in values in the StringMap or in
  the process' environment
* implement some tests
@ghost ghost added the In-PR This issue has a related PR label Feb 25, 2021
christapley added a commit to christapley/terminal that referenced this issue Mar 8, 2021
* Use INHERITABLE_SETTING macro
christapley added a commit to christapley/terminal that referenced this issue Mar 8, 2021
@zadjii-msft zadjii-msft modified the milestones: Terminal Backlog, Backlog Jan 4, 2022
@zadjii-msft zadjii-msft modified the milestones: Backlog, 22H1 Jan 4, 2022
@jacob-pro
Copy link

@Merith-TK A simple work around I am using for MSYS is to use env.exe to set environment variables like

C:\msys64\usr\bin\env.exe MSYSTEM=MINGW64 CHERE_INVOKING=1 /usr/bin/bash.exe --login

(msys2/msys2.github.io#215)

@volviq
Copy link

volviq commented Oct 19, 2022

Is this features going to be implemented anytime soon?

DHowett pushed a commit that referenced this issue Apr 11, 2023
Existing environment variables can be referenced by enclosing the name
in percent characters (e.g. `%PATH%`).

Resurrects #9287 by @christapley.

Tests added and manually tested.

Closes #2785
Closes #9233

Co-authored-by: Chris Tapley <chris.tapley.81@gmail.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Apr 11, 2023
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 Area-TerminalConnection Issues pertaining to the terminal<->backend connection interface Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR 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.
Projects
None yet
9 participants