|
| 1 | +# This file must be used with "source bin/activate" *from bash* |
| 2 | +# you cannot run it directly |
| 3 | + |
| 4 | +deactivate () { |
| 5 | + # reset old environment variables |
| 6 | + if [ -n "$_OLD_VIRTUAL_PATH" ] ; then |
| 7 | + PATH="$_OLD_VIRTUAL_PATH" |
| 8 | + export PATH |
| 9 | + unset _OLD_VIRTUAL_PATH |
| 10 | + fi |
| 11 | + if [ -n "$_OLD_VIRTUAL_ENCORECHOME" ] ; then |
| 12 | + ENCORECHOME="$_OLD_VIRTUAL_ENCORECHOME" |
| 13 | + export ENCORECHOME |
| 14 | + unset _OLD_VIRTUAL_ENCORECHOME |
| 15 | + fi |
| 16 | + |
| 17 | + # This should detect bash and zsh, which have a hash command that must |
| 18 | + # be called to get it to forget past commands. Without forgetting |
| 19 | + # past commands the $PATH changes we made may not be respected |
| 20 | + if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then |
| 21 | + hash -r 2>/dev/null |
| 22 | + fi |
| 23 | + |
| 24 | + if [ -n "$_OLD_VIRTUAL_PS1" ] ; then |
| 25 | + PS1="$_OLD_VIRTUAL_PS1" |
| 26 | + export PS1 |
| 27 | + unset _OLD_VIRTUAL_PS1 |
| 28 | + fi |
| 29 | + |
| 30 | + unset ENCOREC_VIRTUAL_ENV |
| 31 | + if [ ! "$1" = "nondestructive" ] ; then |
| 32 | + # Self destruct! |
| 33 | + unset -f deactivate |
| 34 | + fi |
| 35 | +} |
| 36 | + |
| 37 | +# unset irrelevant variables |
| 38 | +deactivate nondestructive |
| 39 | + |
| 40 | +ENCOREC_VIRTUAL_ENV=$(pwd) |
| 41 | +export ENCOREC_VIRTUAL_ENV |
| 42 | + |
| 43 | +_OLD_VIRTUAL_PATH="$PATH" |
| 44 | +PATH="$ENCOREC_VIRTUAL_ENV/release:$PATH" |
| 45 | +export PATH |
| 46 | + |
| 47 | +# unset ENCORECHOME if set |
| 48 | +# this will fail if ENCORECHOME is set to the empty string (which is bad anyway) |
| 49 | +# could use `if (set -u; : $ENCORECHOME) ;` in bash |
| 50 | +if [ -n "$ENCORECHOME" ] ; then |
| 51 | + _OLD_VIRTUAL_ENCORECHOME="$ENCORECHOME" |
| 52 | + unset ENCORECHOME |
| 53 | +fi |
| 54 | + |
| 55 | +if [ -z "$ENCOREC_VIRTUAL_ENV_DISABLE_PROMPT" ] ; then |
| 56 | + _OLD_VIRTUAL_PS1="$PS1" |
| 57 | + if [ "x" != x ] ; then |
| 58 | + PS1="$PS1" |
| 59 | + else |
| 60 | + if [ "`basename \"$ENCOREC_VIRTUAL_ENV\"`" = "__" ] ; then |
| 61 | + # special case for Aspen magic directories |
| 62 | + # see http://www.zetadev.com/software/aspen/ |
| 63 | + PS1="[`basename \`dirname \"$ENCOREC_VIRTUAL_ENV\"\``] $PS1" |
| 64 | + else |
| 65 | + PS1="(`basename \"$ENCOREC_VIRTUAL_ENV\"`)$PS1" |
| 66 | + fi |
| 67 | + fi |
| 68 | + export PS1 |
| 69 | +fi |
| 70 | + |
| 71 | +# This should detect bash and zsh, which have a hash command that must |
| 72 | +# be called to get it to forget past commands. Without forgetting |
| 73 | +# past commands the $PATH changes we made may not be respected |
| 74 | +if [ -n "$BASH" -o -n "$ZSH_VERSION" ] ; then |
| 75 | + hash -r 2>/dev/null |
| 76 | +fi |
0 commit comments