Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

activate.ps1 1.7 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
  1. $script:THIS_PATH = $myinvocation.mycommand.path
  2. $script:BASE_DIR = Split-Path (Resolve-Path "$THIS_PATH/..") -Parent
  3. function global:deactivate([switch] $NonDestructive) {
  4. if (Test-Path variable:_OLD_VIRTUAL_PATH) {
  5. $env:PATH = $variable:_OLD_VIRTUAL_PATH
  6. Remove-Variable "_OLD_VIRTUAL_PATH" -Scope global
  7. }
  8. if (Test-Path function:_old_virtual_prompt) {
  9. $function:prompt = $function:_old_virtual_prompt
  10. Remove-Item function:\_old_virtual_prompt
  11. }
  12. if ($env:VIRTUAL_ENV) {
  13. Remove-Item env:VIRTUAL_ENV -ErrorAction SilentlyContinue
  14. }
  15. if (!$NonDestructive) {
  16. # Self destruct!
  17. Remove-Item function:deactivate
  18. Remove-Item function:pydoc
  19. }
  20. }
  21. function global:pydoc {
  22. python -m pydoc $args
  23. }
  24. # unset irrelevant variables
  25. deactivate -nondestructive
  26. $VIRTUAL_ENV = $BASE_DIR
  27. $env:VIRTUAL_ENV = $VIRTUAL_ENV
  28. New-Variable -Scope global -Name _OLD_VIRTUAL_PATH -Value $env:PATH
  29. $env:PATH = "$env:VIRTUAL_ENV/Scripts;" + $env:PATH
  30. if (!$env:VIRTUAL_ENV_DISABLE_PROMPT) {
  31. function global:_old_virtual_prompt {
  32. ""
  33. }
  34. $function:_old_virtual_prompt = $function:prompt
  35. if ("" -ne "") {
  36. function global:prompt {
  37. # Add the custom prefix to the existing prompt
  38. $previous_prompt_value = & $function:_old_virtual_prompt
  39. ("" + $previous_prompt_value)
  40. }
  41. }
  42. else {
  43. function global:prompt {
  44. # Add a prefix to the current prompt, but don't discard it.
  45. $previous_prompt_value = & $function:_old_virtual_prompt
  46. $new_prompt_value = "($( Split-Path $env:VIRTUAL_ENV -Leaf )) "
  47. ($new_prompt_value + $previous_prompt_value)
  48. }
  49. }
  50. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...