1
- # This file should be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
1
+ # This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
2
2
# Do not run it directly.
3
3
4
4
function deactivate -d ' Exit virtualenv mode and return to the normal environment.'
5
- if test -n $_ VIRTUALENV_OLD_PATH
6
- set -gx PATH $_ VIRTUALENV_OLD_PATH
7
- set -e _VIRTUALENV_OLD_PATH
5
+ # reset old environment variables
6
+ if test -n " $_ OLD_VIRTUAL_PATH"
7
+ set -gx PATH $_ OLD_VIRTUAL_PATH
8
+ set -e _OLD_VIRTUAL_PATH
8
9
end
9
10
10
- if test -n $_ VIRTUALENV_OLD_PYTHONHOME
11
- set -gx PYTHONHOME $_ VIRTUALENV_OLD_PYTHONHOME
12
- set -e _VIRTUALENV_OLD_PYTHONHOME
11
+ if test -n " $_ OLD_VIRTUAL_PYTHONHOME "
12
+ set -gx PYTHONHOME $_ OLD_VIRTUAL_PYTHONHOME
13
+ set -e _OLD_VIRTUAL_PYTHONHOME
13
14
end
14
15
15
- if test -n $_ VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE
16
+ if test -n " $_ OLD_FISH_PROMPT_OVERRIDE "
16
17
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
17
18
set -l fish_function_path
18
19
19
20
# Erase virtualenv's `fish_prompt` and restore the original.
20
21
functions -e fish_prompt
21
22
functions -c _old_fish_prompt fish_prompt
22
23
functions -e _old_fish_prompt
23
- set -e _VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE
24
+ set -e _OLD_FISH_PROMPT_OVERRIDE
24
25
end
25
26
26
27
set -e VIRTUAL_ENV
27
28
28
- if test $argv [1] != ' nondestructive'
29
+ if test " $argv [1]" != ' nondestructive'
29
30
# Self-destruct!
30
31
functions -e deactivate
31
32
end
@@ -36,35 +37,31 @@ deactivate nondestructive
36
37
37
38
set -gx VIRTUAL_ENV " __VIRTUAL_ENV__"
38
39
39
- set -gx _VIRTUALENV_OLD_PATH $PATH
40
- set -gx PATH $VIRTUAL_ENV /" __BIN_NAME__" $PATH
40
+ set -gx _OLD_VIRTUAL_PATH $PATH
41
+ set -gx PATH " $VIRTUAL_ENV /__BIN_NAME__" $PATH
41
42
42
43
# Unset `$PYTHONHOME` if set.
43
44
if set -q PYTHONHOME
44
- set -gx _VIRTUALENV_OLD_PYTHONHOME $PYTHONHOME
45
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
45
46
set -e PYTHONHOME
46
47
end
47
48
48
- if test \ ( -z $VIRTUAL_ENV_DISABLE_PROMPT \ )
49
+ if test -z " $VIRTUAL_ENV_DISABLE_PROMPT "
49
50
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
50
51
functions -c fish_prompt _old_fish_prompt
51
52
52
53
function fish_prompt
53
- # Save the current $status, for fish_prompts that display it.
54
- set -l old_status $status
55
54
56
55
# Prompt override provided?
57
56
# If not, just prepend the environment name.
58
57
if test -n " __VIRTUAL_PROMPT__"
59
58
printf ' %s%s' " __VIRTUAL_PROMPT__" (set_color normal)
60
59
else
61
- printf ' %svirtualenv:%s %s%s%s \ n ' (set_color white) (set_color normal) (set_color -b black white) (basename $VIRTUAL_ENV ) (set_color normal)
60
+ printf ' %s( %s%s)%s ' (set_color normal) (set_color -b black -o white) (basename " $VIRTUAL_ENV " ) (set_color normal)
62
61
end
63
-
64
- # Restore the original $status
65
- echo " exit $old_status " | source
62
+
66
63
_old_fish_prompt
67
64
end
68
65
69
- set -gx _VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE $VIRTUAL_ENV
66
+ set -gx _OLD_FISH_PROMPT_OVERRIDE " $VIRTUAL_ENV "
70
67
end
0 commit comments