A tiny helper to quickly activate global UV-created virtual environments by name just like workon.
- Windows + PowerShell (Other operations: to be continued.)
- UV installed
- A directory to store your global virtual environments
- Choose a folder to keep your global UV virtual environments, e.g.
D:\Dev\uv_venvs. - Create environments in that folder with UV. The simplest way:
uv venv <env_name>. For advanced options (e.g., specify Python version), refer to the UV documentation. - Move these three files into that folder:
uvworkon.ps1setup_uvworkon_alias.ps1uninstall_uvworkon_alias.ps1
- Open PowerShell (pwsh) and run
.\setup_uvworkon_alias.ps1to write the uvworkon function into your PowerShell profile (#region uvworkon initialize ... #endregion). - Restart PowerShell.
- List available environments (folders with
Scripts\activate.batin the current directory):
uvworkon- Activate a specific environment:
uvworkon <env_name>Remove the alias block from your PowerShell profile:
.\uninstall_uvworkon_alias.ps1