Skip to content

Commit bcf6c08

Browse files
committed
Fix activate.fish
- Re-use old variable names - Requote to fix param expansion problems - Use traditional prompt look
1 parent 60e494e commit bcf6c08

File tree

2 files changed

+31
-36
lines changed

2 files changed

+31
-36
lines changed

virtualenv.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,21 +2051,19 @@ def convert(s):
20512051

20522052
##file activate.fish
20532053
ACTIVATE_FISH = convert("""
2054-
eJyNVWFP2zAQ/Z5fcUBRYaJB+zppmtjoRCWgVemQpjG5bnIh3lw7s50A0378LmmTODQI8qFpnHd3
2055-
z773LgewSIWFREgEm+pcxrBCyC3G9CPUPSxDWAl1yiMnCu4wTIRNl/DuQbhUKOBgcqVKXLkOR5A6
2056-
l304PS2fbIpShpFewzFYtFZo9S4MDuBcg9KuDAThIBYGIyefwiBIckVVtIIY63IwimE4fiRcIYzL
2057-
uURVwFrHCFzFYNDlRoHT4FKkpGbNJRBCGK3WqFw4DIAukYBD62CkYMBuJ/PFt7PL8fUtm16es9nZ
2058-
4qIClZdFAt0/Qrn4FijCixhUcfB68e+Li+n1xfRqvEuhefX2sB46XeSbSH2d3Fyw2Xx6NVuw6e14
2059-
Pp+ct3UO4IYqcQW4ztwTSB3RiS8HZbtZ3T6WcUcSoa5wKfVD1RuDa10QVCewrMCZ0ZRhWYusjrW0
2060-
i2XY3ZaE3fSBx2hsuEVPH0P7rMZGKtZpgxUZbcS9UFy2dfzy4MX2ASJgWsbMQ70WgTsRr/XtxR40
2061-
HdwGbuMYBXY7O+Dmvvjx/ifsfYSh0iqmRZOXrsJhp5syGdXv9vrJt25sKFQ0DuCbKmkIY1BiwRWZ
2062-
lBvBVxJtGHge7pYPglrjHnnYZ8x7ZGy/hfV5DAaV07qG9RKcUr7Pk2t2fXY1pmRbeEN5OWidsSzP
2063-
jBbDYHOH0R945psXmXgm7QtBP1F1ZnV77o5g9LfDmJ1Pbs4+X463bYe742DToi86e6pkG+V00HTI
2064-
XXE3Q5OT7J/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3ZXZxSjY/UPvD5xYpJmGZ8MmPPpZyts6GOxvnSsZjB/6t3fDfcPD/dz6KrPXUqOr
2064+
3F6vvdq6kg8Dk1qNn4pq75uaVH2VnomwBoeznR2j2S5YFqgUs2PYIgr7n3zxMOO1G/Af4Jf7mmQK
2065+
M3v08hT+8BU0xaPj/MFz1MBe/eQ4cNyTKSbMGjqX+lJ3GuFwZa+frCSXav9V6B4yINf4n3RXLmPX
2066+
JT2P95d6S1hyuvoNPQnPW2bQ7i7t0HFHqrc17L5JpTKyexpnQt3qlfyaJsNJ3VJt/wCdimbs
20692067
""")
20702068

20712069
##file activate.csh

virtualenv_embedded/activate.fish

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,32 @@
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*.
22
# Do not run it directly.
33

44
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
89
end
910

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
1314
end
1415

15-
if test -n $_VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE
16+
if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
1617
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
1718
set -l fish_function_path
1819

1920
# Erase virtualenv's `fish_prompt` and restore the original.
2021
functions -e fish_prompt
2122
functions -c _old_fish_prompt fish_prompt
2223
functions -e _old_fish_prompt
23-
set -e _VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE
24+
set -e _OLD_FISH_PROMPT_OVERRIDE
2425
end
2526

2627
set -e VIRTUAL_ENV
2728

28-
if test $argv[1] != 'nondestructive'
29+
if test "$argv[1]" != 'nondestructive'
2930
# Self-destruct!
3031
functions -e deactivate
3132
end
@@ -36,35 +37,31 @@ deactivate nondestructive
3637

3738
set -gx VIRTUAL_ENV "__VIRTUAL_ENV__"
3839

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
4142

4243
# Unset `$PYTHONHOME` if set.
4344
if set -q PYTHONHOME
44-
set -gx _VIRTUALENV_OLD_PYTHONHOME $PYTHONHOME
45+
set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
4546
set -e PYTHONHOME
4647
end
4748

48-
if test \( -z $VIRTUAL_ENV_DISABLE_PROMPT \)
49+
if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
4950
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
5051
functions -c fish_prompt _old_fish_prompt
5152

5253
function fish_prompt
53-
# Save the current $status, for fish_prompts that display it.
54-
set -l old_status $status
5554

5655
# Prompt override provided?
5756
# If not, just prepend the environment name.
5857
if test -n "__VIRTUAL_PROMPT__"
5958
printf '%s%s' "__VIRTUAL_PROMPT__" (set_color normal)
6059
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)
6261
end
63-
64-
# Restore the original $status
65-
echo "exit $old_status" | source
62+
6663
_old_fish_prompt
6764
end
6865

69-
set -gx _VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE $VIRTUAL_ENV
66+
set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
7067
end

0 commit comments

Comments
 (0)