python/virtualenv/virtualenv_embedded/activate.fish

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial