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

Allow using variables as part of path and args values in terminal settings #120667

Closed
pszlazak opened this issue Apr 6, 2021 · 9 comments
Closed
Assignees
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code) terminal General terminal issues that don't fall under another label

Comments

@pszlazak
Copy link

pszlazak commented Apr 6, 2021

Using Terminal profiles introduced in 1.55 (via #45444) I tried to use system variables as part of path and args values but w/o success.

Example for path:

  • this one works:
"terminal.integrated.profiles.windows": {
        "Yet Another PowerShell": {
            "path": "c:\\Users\\Piotr\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe"
        }
}
  • this one does not work - it's not even listed on the list of available profiles:
"terminal.integrated.profiles.windows": {
        "Yet Another PowerShell": {
            "path": "%LOCALAPPDATA%\\Microsoft\\WindowsApps\\pwsh.exe"
        },
}

Same thing is observed if variable is used as part of value of args. Following configuration:

"terminal.integrated.profiles.windows": {
        "Yet Another PowerShell": {
            "path": "c:\\Users\\Piotr\\AppData\\Local\\Microsoft\\WindowsApps\\pwsh.exe"
            "args": [
                "-noexit",
                "-file",
                "%APPDATA%\\PowerShell\\oh-my-posh.ps1"
            ]
        }
}

fails with error:

The terminal process "c:\Users\Piotr\AppData\Local\Microsoft\WindowsApps\pwsh.exe '-noexit', '-file', '%APPDATA%\PowerShell\oh-my-posh.ps1'" terminated with exit code: 64.
@meganrogge meganrogge added feature-request Request for new features or functionality terminal General terminal issues that don't fall under another label labels Apr 22, 2021
@Tyriar
Copy link
Member

Tyriar commented Jul 6, 2021

This is supported but using a different cross-platform syntax:

"terminal.integrated.profiles.windows": {
        "Yet Another PowerShell": {
            "path": "${env:LOCALAPPDATA}\\Microsoft\\WindowsApps\\pwsh.exe"
        }
}

The %VAR% syntax may work but only if your shell resolves them, VS Code will not by design.

You can read more about the variables at https://code.visualstudio.com/docs/editor/variables-reference

@Tyriar Tyriar closed this as completed Jul 6, 2021
@Tyriar Tyriar added *question Issue represents a question, should be posted to StackOverflow (VS Code) and removed feature-request Request for new features or functionality labels Jul 6, 2021
@Tyriar Tyriar removed this from the Backlog milestone Jul 6, 2021
@Tyriar
Copy link
Member

Tyriar commented Jul 6, 2021

Created microsoft/vscode-docs#4661 to add to the documentation

@dhgsg
Copy link

dhgsg commented Jul 7, 2021

This example still does not work, though:

"tmux test": { "path": "tmux", "args": [ "new-session", "-A", "-s", "${workspaceFolderBasename}" ]

The session ends up being named "${workspaceFolderBasename}" instead of using the name of the folder.

@Tyriar
Copy link
Member

Tyriar commented Jul 7, 2021

@dhgsg I'll look into it in the similar sounding #126066. Can you post that example with machine information there? (OS, version, remote info if any, etc.)

@Tyriar
Copy link
Member

Tyriar commented Jul 7, 2021

@dhgsg you might also be seeing #115560

@dhgsg
Copy link

dhgsg commented Jul 7, 2021

Both of those look like they are related to what I see, thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*question Issue represents a question, should be posted to StackOverflow (VS Code) terminal General terminal issues that don't fall under another label
Projects
None yet
Development

No branches or pull requests

5 participants
@Tyriar @pszlazak @dhgsg @meganrogge and others