Closed
Description
Refs: #227
- macOS : @meganrogge
- linux : @joshspicer
- windows: @Tyriar
Complexity: 4
Requirements
Use extension build from here: https://github.com/microsoft/vscode-python-environments/actions/runs/14048386114/artifacts/2812047113
NOTE This is NOT shipped in pre-release because if this has issues it can leave users shell in a bad state.
Validation
✋ NOTE the following steps will change your shell startup scripts. Please take a backup of your shell startup.
Setup
- Do this external to VS Code. Setup a directory with a python file and an environment. Creating python environment can be done by running
python -m venv .venv
from the workspace directory. - Open that workspace and install the above extension. Make sure both python extension and python envs extension are activated.
- Note: You may need to reload, if you already had python extension.
- Go to settings and change this
python-envs.terminal.autoActivationType
setting toshellStartup
. - That should show you this:
- Update Shell Profile will apply changes to all shell profiles listed in the modal.
- See Activation using Shell Startup #227 for details on the changes made.
Things to Check
- Opening a terminal in vscode should have the virtual environment activated. A test is to print
VRITUAL_ENV
env variable for your shell. likeecho $VIRTUAL_ENV
. Your prompt may also show.venv
. - Reloading VS Code should give you activated terminals. you should not see any modals asking you to update shell startup. This is a one time change.
- Terminal shells outside of VS Code should not have any impact from this change.
- This should also work with any prompt customization, like
starship
,oh-my-posh
, etc. - There is a command to revert all the changes:
Python Envs: Revert Shell Startup Script Changes
. running this should also switch you back tocommand
mode in thepython-envs.terminal.autoActivationType
. - Revert should remove changes. Except in
cmd
, it will only remove activation code. Any changes to registry will remain. But it will not affectcmd
execution. - After reverting you should get command activation. That is opening a terminal in VS Code will cause a command to be sent to it.
- Switching the setting from
shellStartup
tocommand
should NOT revert the changes made to various shells. But it should change the environment contributed to the terminals in VS Code (i.e., you should see warning for relaunch on terminal tabs)
Windows
- cmd
- Powershell 5
- pwsh 7.5
- gitbash
- [Optional] nu
Mac
- pwsh 7.5
- zsh
- bash
- fish
- nu
Linux
- pwsh 7.5
- zsh
- bash
- fish
- nu