activate.fish 2.5 KB

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