| OLD | NEW |
| (Empty) |
| 1 # This file must be used with "source bin/activate.fish" *from fish* (http://fis
hshell.com) | |
| 2 # you cannot run it directly | |
| 3 | |
| 4 function deactivate -d "Exit virtualenv and return to normal shell environment" | |
| 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 | |
| 9 end | |
| 10 if test -n "$_OLD_VIRTUAL_PYTHONHOME" | |
| 11 set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME | |
| 12 set -e _OLD_VIRTUAL_PYTHONHOME | |
| 13 end | |
| 14 | |
| 15 if test -n "$_OLD_FISH_PROMPT_OVERRIDE" | |
| 16 # set an empty local fish_function_path, so fish_prompt doesn't automati
cally reload | |
| 17 set -l fish_function_path | |
| 18 # erase the virtualenv's fish_prompt function, and restore the original | |
| 19 functions -e fish_prompt | |
| 20 functions -c _old_fish_prompt fish_prompt | |
| 21 functions -e _old_fish_prompt | |
| 22 set -e _OLD_FISH_PROMPT_OVERRIDE | |
| 23 end | |
| 24 | |
| 25 set -e VIRTUAL_ENV | |
| 26 if test "$argv[1]" != "nondestructive" | |
| 27 # Self destruct! | |
| 28 functions -e deactivate | |
| 29 end | |
| 30 end | |
| 31 | |
| 32 # unset irrelevant variables | |
| 33 deactivate nondestructive | |
| 34 | |
| 35 set -gx VIRTUAL_ENV "__VIRTUAL_ENV__" | |
| 36 | |
| 37 set -gx _OLD_VIRTUAL_PATH $PATH | |
| 38 set -gx PATH "$VIRTUAL_ENV/__BIN_NAME__" $PATH | |
| 39 | |
| 40 # unset PYTHONHOME if set | |
| 41 if set -q PYTHONHOME | |
| 42 set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME | |
| 43 set -e PYTHONHOME | |
| 44 end | |
| 45 | |
| 46 if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" | |
| 47 # fish uses a function instead of an env var to generate the prompt. | |
| 48 | |
| 49 # copy the current fish_prompt function as the function _old_fish_prompt | |
| 50 functions -c fish_prompt _old_fish_prompt | |
| 51 | |
| 52 # with the original prompt function copied, we can override with our own. | |
| 53 function fish_prompt | |
| 54 # Prompt override? | |
| 55 if test -n "__VIRTUAL_PROMPT__" | |
| 56 printf "%s%s" "__VIRTUAL_PROMPT__" (set_color normal) | |
| 57 _old_fish_prompt | |
| 58 return | |
| 59 end | |
| 60 # ...Otherwise, prepend env | |
| 61 set -l _checkbase (basename "$VIRTUAL_ENV") | |
| 62 if test $_checkbase = "__" | |
| 63 # special case for Aspen magic directories | |
| 64 # see http://www.zetadev.com/software/aspen/ | |
| 65 printf "%s[%s]%s " (set_color -b blue white) (basename (dirname "$VI
RTUAL_ENV")) (set_color normal) | |
| 66 _old_fish_prompt | |
| 67 else | |
| 68 printf "%s(%s)%s" (set_color -b blue white) (basename "$VIRTUAL_ENV"
) (set_color normal) | |
| 69 _old_fish_prompt | |
| 70 end | |
| 71 end | |
| 72 | |
| 73 set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" | |
| 74 end | |
| OLD | NEW |