activate.fish 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # This file must be used with "source <venv>/bin/activate.fish" *from fish*
  2. # (https://fishshell.com/); you cannot run it directly.
  3. function deactivate -d "Exit virtual environment and return to normal shell environment"
  4. # reset old environment variables
  5. if test -n "$_OLD_VIRTUAL_PATH"
  6. set -gx PATH $_OLD_VIRTUAL_PATH
  7. set -e _OLD_VIRTUAL_PATH
  8. end
  9. if test -n "$_OLD_VIRTUAL_PYTHONHOME"
  10. set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
  11. set -e _OLD_VIRTUAL_PYTHONHOME
  12. end
  13. if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
  14. functions -e fish_prompt
  15. set -e _OLD_FISH_PROMPT_OVERRIDE
  16. functions -c _old_fish_prompt fish_prompt
  17. functions -e _old_fish_prompt
  18. end
  19. set -e VIRTUAL_ENV
  20. set -e VIRTUAL_ENV_PROMPT
  21. if test "$argv[1]" != "nondestructive"
  22. # Self-destruct!
  23. functions -e deactivate
  24. end
  25. end
  26. # Unset irrelevant variables.
  27. deactivate nondestructive
  28. set -gx VIRTUAL_ENV "/Users/federicaspinelli/Semantization_Interface/venv"
  29. set -gx _OLD_VIRTUAL_PATH $PATH
  30. set -gx PATH "$VIRTUAL_ENV/bin" $PATH
  31. # Unset PYTHONHOME if set.
  32. if set -q PYTHONHOME
  33. set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
  34. set -e PYTHONHOME
  35. end
  36. if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
  37. # fish uses a function instead of an env var to generate the prompt.
  38. # Save the current fish_prompt function as the function _old_fish_prompt.
  39. functions -c fish_prompt _old_fish_prompt
  40. # With the original prompt function renamed, we can override with our own.
  41. function fish_prompt
  42. # Save the return status of the last command.
  43. set -l old_status $status
  44. # Output the venv prompt; color taken from the blue of the Python logo.
  45. printf "%s%s%s" (set_color 4B8BBE) "(venv) " (set_color normal)
  46. # Restore the return status of the previous command.
  47. echo "exit $old_status" | .
  48. # Output the original/"old" prompt.
  49. _old_fish_prompt
  50. end
  51. set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
  52. set -gx VIRTUAL_ENV_PROMPT "(venv) "
  53. end