summaryrefslogtreecommitdiff
path: root/virtualenv_embedded
diff options
context:
space:
mode:
authorMatthew Iversen <teh.ivo@gmail.com>2015-09-20 19:39:44 +1000
committerMatthew Iversen <teh.ivo@gmail.com>2015-09-20 19:39:44 +1000
commitbcf6c085a8ac68c3e2e2fa2b00330b9dfdca5bb9 (patch)
tree029ed45678a4ca5e3562da845a00a32c8acdc583 /virtualenv_embedded
parent60e494e3047b1e7da6d2c3b5c5ba2587b1343e44 (diff)
downloadvirtualenv-bcf6c085a8ac68c3e2e2fa2b00330b9dfdca5bb9.tar.gz
Fix activate.fish
- Re-use old variable names - Requote to fix param expansion problems - Use traditional prompt look
Diffstat (limited to 'virtualenv_embedded')
-rw-r--r--virtualenv_embedded/activate.fish39
1 files changed, 18 insertions, 21 deletions
diff --git a/virtualenv_embedded/activate.fish b/virtualenv_embedded/activate.fish
index 27d7dc6..4501170 100644
--- a/virtualenv_embedded/activate.fish
+++ b/virtualenv_embedded/activate.fish
@@ -1,18 +1,19 @@
-# This file should be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
+# This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
# Do not run it directly.
function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
- if test -n $_VIRTUALENV_OLD_PATH
- set -gx PATH $_VIRTUALENV_OLD_PATH
- set -e _VIRTUALENV_OLD_PATH
+ # reset old environment variables
+ if test -n "$_OLD_VIRTUAL_PATH"
+ set -gx PATH $_OLD_VIRTUAL_PATH
+ set -e _OLD_VIRTUAL_PATH
end
- if test -n $_VIRTUALENV_OLD_PYTHONHOME
- set -gx PYTHONHOME $_VIRTUALENV_OLD_PYTHONHOME
- set -e _VIRTUALENV_OLD_PYTHONHOME
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
+ set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
+ set -e _OLD_VIRTUAL_PYTHONHOME
end
- if test -n $_VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
# Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
set -l fish_function_path
@@ -20,12 +21,12 @@ function deactivate -d 'Exit virtualenv mode and return to the normal environmen
functions -e fish_prompt
functions -c _old_fish_prompt fish_prompt
functions -e _old_fish_prompt
- set -e _VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE
+ set -e _OLD_FISH_PROMPT_OVERRIDE
end
set -e VIRTUAL_ENV
- if test $argv[1] != 'nondestructive'
+ if test "$argv[1]" != 'nondestructive'
# Self-destruct!
functions -e deactivate
end
@@ -36,35 +37,31 @@ deactivate nondestructive
set -gx VIRTUAL_ENV "__VIRTUAL_ENV__"
-set -gx _VIRTUALENV_OLD_PATH $PATH
-set -gx PATH $VIRTUAL_ENV/"__BIN_NAME__" $PATH
+set -gx _OLD_VIRTUAL_PATH $PATH
+set -gx PATH "$VIRTUAL_ENV/__BIN_NAME__" $PATH
# Unset `$PYTHONHOME` if set.
if set -q PYTHONHOME
- set -gx _VIRTUALENV_OLD_PYTHONHOME $PYTHONHOME
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
set -e PYTHONHOME
end
-if test \( -z $VIRTUAL_ENV_DISABLE_PROMPT \)
+if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
# Copy the current `fish_prompt` function as `_old_fish_prompt`.
functions -c fish_prompt _old_fish_prompt
function fish_prompt
- # Save the current $status, for fish_prompts that display it.
- set -l old_status $status
# Prompt override provided?
# If not, just prepend the environment name.
if test -n "__VIRTUAL_PROMPT__"
printf '%s%s' "__VIRTUAL_PROMPT__" (set_color normal)
else
- printf '%svirtualenv:%s %s%s%s\n' (set_color white) (set_color normal) (set_color -b black white) (basename $VIRTUAL_ENV) (set_color normal)
+ printf '%s(%s%s)%s' (set_color normal) (set_color -b black -o white) (basename "$VIRTUAL_ENV") (set_color normal)
end
-
- # Restore the original $status
- echo "exit $old_status" | source
+
_old_fish_prompt
end
- set -gx _VIRTUALENV_OLD_FISH_PROMPT_OVERRIDE $VIRTUAL_ENV
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
end