When debugging Python using VS Code, I am using windows terminal with PowerShell as my external terminal. For normal use, I have starting directory in PowerShell set as %USERPROFILE%
(C:\Users\username) but when running python code I need to change the starting folder to %__CD__%
(C:\Windows\system32) so that the current working directory would be the same as the python file I am running. (I found that this is the way it works thanks to testing.) This is necessary when working with files using python. However, I don't want to change the startingDirectory setting in PowerShell setting to %__CD__%
due to practicality and personal preference.
So my question is, is it possible to temporarily set the startingDirectory setting for PowerShell from VSCode just to run the code? So that when i open WT for any other non debugging reason the starting directory is %USERPROFILE%.
These are my VS Code launch configurations:
"launch": {
"configurations": [
{
"name": "Python: Integrated Terminal",
"type": "python",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"console": "integratedTerminal"
},
{
"name": "Python: External Terminal",
"type": "python",
"request": "launch",
"program": "${file}",
"console": "externalTerminal"
}
]
},
"terminal.external.windowsExec":"wt -p cmd cmd",
This is my PowerShell configuration:
{
"colorScheme": "One Half Dark",
"commandline": "powershell.exe",
"fontFace": "Consolas",
guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
hidden": false,
name": "Windows PowerShell",
startingDirectory": "%USERPROFILE%",
tabTitle": "PowerShell"
}
Thanks for any suggestions.