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