comparison bin/activate.ps1 @ 1:64071f2a4cf0 draft default tip

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