Setting environment variables for integrated terminal
Setting environment variables for integrated terminal
I am seeking help figuring out how to setup environment variables for integrated terminal within Visual Studio Code. Currently I am able to do so with .env file inside my workspace folder, but I'd like to change the filename for this file and create another one or two, let's say dev.env and prod.env. Setting "python.envFile" for my workspace doesn't do the trick and from what I understand changing things in launch.json is for debugging.
The overall goal of all this (and that is important) is to run flask shell (integrated shell for flask web framework, python) with a certain set of env variables and be able to change them by swapping files. I know I could set these by introducing "terminal.integrated.env.osx" to my workspace settings, but I'd rather get these variables from a file.
Thanks a lot for your time and help.
UPD >>
I guess one way to go about it would be to create two tasks as such:
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
"label": "FLASK SHELL DEV",
"type": "shell",
"command": "source $workspaceFolder/dev.env && $config:python.pythonPath -m flask shell",
"problemMatcher":
,
"label": "FLASK SHELL PROD",
"type": "shell",
"command": "source $workspaceFolder/prod.env && $config:python.pythonPath -m flask shell",
"problemMatcher":
]
but the question stands. Is there a way to do the same with integrated terminal?
1 Answer
1
If you don't want to set environment variables using the terminal you can do it using configuration files.
Thanks for contributing an answer to Stack Overflow!
But avoid …
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
But avoid …
To learn more, see our tips on writing great answers.
Required, but never shown
Required, but never shown
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Thank you for your comment. While I do understand this piece of documentation, I don't think I quite understand how this answers my question, because I am faced with the same dilemma as in my initial post where I have to set an ENV variable before I run the shell. If you are positive that this is the answer to my question, could you please show an example of running an interactive flask shell in VS Code's integrated terminal using env variables from a file?
– jabbson
Sep 4 at 4:29