activate.fish 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # This Source Code Form is subject to the terms of the Mozilla Public
  2. # License, v. 2.0. If a copy of the MPL was not distributed with this
  3. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. # This file must be used with "source bin/activate.fish" *from fish*
  5. # you cannot run it directly
  6. # Much of this code is based off of the activate.fish file for the
  7. # virtualenv project. http://ur1.ca/ehmd6
  8. function deactivate -d "Exit addon-sdk and return to normal shell environment"
  9. if test -n "$_OLD_VIRTUAL_PATH"
  10. set -gx PATH $_OLD_VIRTUAL_PATH
  11. set -e _OLD_VIRTUAL_PATH
  12. end
  13. if test -n "$_OLD_PYTHONPATH"
  14. set -gx PYTHONPATH $_OLD_PYTHONPATH
  15. set -e _OLD_PYTHONPATH
  16. end
  17. if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
  18. functions -e fish_prompt
  19. set -e _OLD_FISH_PROMPT_OVERRIDE
  20. . ( begin
  21. printf "function fish_prompt\n\t#"
  22. functions _old_fish_prompt
  23. end | psub )
  24. functions -e _old_fish_prompt
  25. end
  26. set -e CUDDLEFISH_ROOT
  27. set -e VIRTUAL_ENV
  28. if test "$argv[1]" != "nondestructive"
  29. functions -e deactivate
  30. end
  31. end
  32. # unset irrelavent variables
  33. deactivate nondestructive
  34. set -gx _OLD_PYTHONPATH $PYTHONPATH
  35. set -gx _OLD_VIRTUAL_PATH $PATH
  36. set -gx _OLD_FISH_PROMPT_OVERRIDE "true"
  37. set VIRTUAL_ENV (pwd)
  38. set -gx CUDDLEFISH_ROOT $VIRTUAL_ENV
  39. set -gx PYTHONPATH "$VIRTUAL_ENV/python-lib" $PYTHONPATH
  40. set -gx PATH "$VIRTUAL_ENV/bin" $PATH
  41. # save the current fish_prompt function as the function _old_fish_prompt
  42. . ( begin
  43. printf "function _old_fish_prompt\n\t#"
  44. functions fish_prompt
  45. end | psub )
  46. # with the original prompt function renamed, we can override with our own.
  47. function fish_prompt
  48. printf "(%s)%s%s" (basename "$VIRTUAL_ENV") (set_color normal) (_old_fish_prompt)
  49. return
  50. end
  51. python -c "from jetpack_sdk_env import welcome; welcome()"