Activate.ps1 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. function global:deactivate ([switch]$NonDestructive) {
  2. # Revert to original values
  3. if (Test-Path function:_OLD_VIRTUAL_PROMPT) {
  4. copy-item function:_OLD_VIRTUAL_PROMPT function:prompt
  5. remove-item function:_OLD_VIRTUAL_PROMPT
  6. }
  7. if (Test-Path env:_OLD_VIRTUAL_PYTHONHOME) {
  8. copy-item env:_OLD_VIRTUAL_PYTHONHOME env:PYTHONHOME
  9. remove-item env:_OLD_VIRTUAL_PYTHONHOME
  10. }
  11. if (Test-Path env:_OLD_VIRTUAL_PATH) {
  12. copy-item env:_OLD_VIRTUAL_PATH env:PATH
  13. remove-item env:_OLD_VIRTUAL_PATH
  14. }
  15. if (Test-Path env:VIRTUAL_ENV) {
  16. remove-item env:VIRTUAL_ENV
  17. }
  18. if (!$NonDestructive) {
  19. # Self destruct!
  20. remove-item function:deactivate
  21. }
  22. }
  23. deactivate -nondestructive
  24. $env:VIRTUAL_ENV="C:\Users\FinnMertens\Desktop\MOTT´ú¸Õ\Coffee Project\venv"
  25. # Set the prompt to include the env name
  26. # Make sure _OLD_VIRTUAL_PROMPT is global
  27. function global:_OLD_VIRTUAL_PROMPT {""}
  28. copy-item function:prompt function:_OLD_VIRTUAL_PROMPT
  29. function global:prompt {
  30. Write-Host -NoNewline -ForegroundColor Green '(venv) '
  31. _OLD_VIRTUAL_PROMPT
  32. }
  33. # Clear PYTHONHOME
  34. if (Test-Path env:PYTHONHOME) {
  35. copy-item env:PYTHONHOME env:_OLD_VIRTUAL_PYTHONHOME
  36. remove-item env:PYTHONHOME
  37. }
  38. # Add the venv to the PATH
  39. copy-item env:PATH env:_OLD_VIRTUAL_PATH
  40. $env:PATH = "$env:VIRTUAL_ENV\Scripts;$env:PATH"