activate.fish 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. if test "$argv[1]" != "nondestructive"
  21. # Self-destruct!
  22. functions -e deactivate
  23. end
  24. end
  25. # Unset irrelevant variables.
  26. deactivate nondestructive
  27. set -gx VIRTUAL_ENV "/usr/local/google/home/abhinand/material-design-icons/update/venv"
  28. set -gx _OLD_VIRTUAL_PATH $PATH
  29. set -gx PATH "$VIRTUAL_ENV/bin" $PATH
  30. # Unset PYTHONHOME if set.
  31. if set -q PYTHONHOME
  32. set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
  33. set -e PYTHONHOME
  34. end
  35. if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
  36. # fish uses a function instead of an env var to generate the prompt.
  37. # Save the current fish_prompt function as the function _old_fish_prompt.
  38. functions -c fish_prompt _old_fish_prompt
  39. # With the original prompt function renamed, we can override with our own.
  40. function fish_prompt
  41. # Save the return status of the last command.
  42. set -l old_status $status
  43. # Output the venv prompt; color taken from the blue of the Python logo.
  44. printf "%s%s%s" (set_color 4B8BBE) "(venv) " (set_color normal)
  45. # Restore the return status of the previous command.
  46. echo "exit $old_status" | .
  47. # Output the original/"old" prompt.
  48. _old_fish_prompt
  49. end
  50. set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
  51. end