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] - Support for variable substitution #550

Open
depascalis opened this issue Sep 26, 2021 · 5 comments
Open

[FEATURE] - Support for variable substitution #550

depascalis opened this issue Sep 26, 2021 · 5 comments

Comments

@depascalis
Copy link

It would be great with support for variable substitutions in paths, especially when working with the same projects on multiple machines.
I don't know how it's implemented, if the API supports adding all variables in one swoop, or if they have to be implement one by one. If the latter, I believe the ${env:} variable would be most useful, with it you can access your system environment variables like ${env:PATH}, ${env:USERPROFILE}, and ${env:WHATEVER}.

This kind of solves this request also #65 with ${env:APPDATA}${pathSeparator}Code${pathSeparator}User which points to vscode user directory on Windows.

@alefragnani
Copy link
Owner

Hi @depascalis ,

There is no support for variable substitution, at first, because there is no API available for that. Any desired variable needs to be manually supported.

But, what variables do you miss, in order to use the same projects on multiple machines?

I mean, you can use ~ or $home as a replacement for your home folder, even if you use different OS on each machine.

Hope this helps

@depascalis
Copy link
Author

I should have read the docs more closely, I just assumed that variables were evaluated everywhere. I found this library though with some predefined variables if you want to proceed https://www.npmjs.com/package/vscode-variables ${env:} is included eg.

I have small "projects" everywhere on my systems, like overrides, tweaks, and hacks of stuff. But depending on the machine, a project can be under local in one case, and roaming in another, some directories aren't even under $home. Also, some projects through work are set up using system environment variables (don't ask) and it would be nice to be able to reference those, especially if and when you get the paths property out to the masses 🚀 It would also just make the config be a bit easier on the eyes :)

This request is more of a nice-to-have in my case atm, so don't bother if it is too much hassle.

@alefragnani
Copy link
Owner

Well, with such a complex scenario, neither if you have projects synced via Settings Sync would be enough 😄

Thanks for the additional info.

@depascalis
Copy link
Author

@alefragnani If you missed it, vscode introduced the platform independent ${userHome} for tasks.json. Maybe add it to mirror the ${home} variable to avoid confusion.

https://code.visualstudio.com/updates/v1_65#_tasks

@thakyZ
Copy link

thakyZ commented Mar 20, 2024

Would you also mind implementing ~ and $home as well as environment variables for options defined in the VSCode settings, such as:

"projectManager.git.baseFolders": [
  "~\\Development\\Git"
],

Because at the moment I have to include an absolute path, which isn't exactly a problem for me, but it would prove very useful for others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants