|
| 1 | +# This file must be used using `. bin/activate.fish` *within a running fish ( http://fishshell.com ) session*. |
| 2 | +# Do not run it directly. |
| 3 | + |
| 4 | +function deactivate -d 'Exit virtualenv mode and return to the normal 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 | + |
| 11 | + if test -n "$_OLD_VIRTUAL_PYTHONHOME" |
| 12 | + set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME |
| 13 | + set -e _OLD_VIRTUAL_PYTHONHOME |
| 14 | + end |
| 15 | + |
| 16 | + if test -n "$_OLD_FISH_PROMPT_OVERRIDE" |
| 17 | + # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`. |
| 18 | + set -l fish_function_path |
| 19 | + |
| 20 | + # Erase virtualenv's `fish_prompt` and restore the original. |
| 21 | + functions -e fish_prompt |
| 22 | + functions -c _old_fish_prompt fish_prompt |
| 23 | + functions -e _old_fish_prompt |
| 24 | + set -e _OLD_FISH_PROMPT_OVERRIDE |
| 25 | + end |
| 26 | + |
| 27 | + set -e VIRTUAL_ENV |
| 28 | + |
| 29 | + if test "$argv[1]" != 'nondestructive' |
| 30 | + # Self-destruct! |
| 31 | + functions -e pydoc |
| 32 | + functions -e deactivate |
| 33 | + end |
| 34 | +end |
| 35 | + |
| 36 | +# Unset irrelevant variables. |
| 37 | +deactivate nondestructive |
| 38 | + |
| 39 | +set -gx VIRTUAL_ENV "/Users/norlihazmeynazroltech/projects/python-arduino-interfacing/venv" |
| 40 | + |
| 41 | +set -gx _OLD_VIRTUAL_PATH $PATH |
| 42 | +set -gx PATH "$VIRTUAL_ENV/bin" $PATH |
| 43 | + |
| 44 | +# Unset `$PYTHONHOME` if set. |
| 45 | +if set -q PYTHONHOME |
| 46 | + set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME |
| 47 | + set -e PYTHONHOME |
| 48 | +end |
| 49 | + |
| 50 | +function pydoc |
| 51 | + python -m pydoc $argv |
| 52 | +end |
| 53 | + |
| 54 | +if test -z "$VIRTUAL_ENV_DISABLE_PROMPT" |
| 55 | + # Copy the current `fish_prompt` function as `_old_fish_prompt`. |
| 56 | + functions -c fish_prompt _old_fish_prompt |
| 57 | + |
| 58 | + function fish_prompt |
| 59 | + # Save the current $status, for fish_prompts that display it. |
| 60 | + set -l old_status $status |
| 61 | + |
| 62 | + # Prompt override provided? |
| 63 | + # If not, just prepend the environment name. |
| 64 | + if test -n "" |
| 65 | + printf '%s%s' "" (set_color normal) |
| 66 | + else |
| 67 | + printf '%s(%s) ' (set_color normal) (basename "$VIRTUAL_ENV") |
| 68 | + end |
| 69 | + |
| 70 | + # Restore the original $status |
| 71 | + echo "exit $old_status" | source |
| 72 | + _old_fish_prompt |
| 73 | + end |
| 74 | + |
| 75 | + set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV" |
| 76 | +end |
0 commit comments