activate.fish 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # This file must be used using `source bin/activate.fish` *within a running fish ( http://fishshell.com ) session*.
  2. # Do not run it directly.
  3. function _bashify_path -d "Converts a fish path to something bash can recognize"
  4. set fishy_path $argv
  5. set bashy_path $fishy_path[1]
  6. for path_part in $fishy_path[2..-1]
  7. set bashy_path "$bashy_path:$path_part"
  8. end
  9. echo $bashy_path
  10. end
  11. function _fishify_path -d "Converts a bash path to something fish can recognize"
  12. echo $argv | tr ':' '\n'
  13. end
  14. function deactivate -d 'Exit virtualenv mode and return to the normal environment.'
  15. # reset old environment variables
  16. if test -n "$_OLD_VIRTUAL_PATH"
  17. # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
  18. if test (echo $FISH_VERSION | head -c 1) -lt 3
  19. set -gx PATH (_fishify_path "$_OLD_VIRTUAL_PATH")
  20. else
  21. set -gx PATH $_OLD_VIRTUAL_PATH
  22. end
  23. set -e _OLD_VIRTUAL_PATH
  24. end
  25. if test -n "$_OLD_VIRTUAL_PYTHONHOME"
  26. set -gx PYTHONHOME "$_OLD_VIRTUAL_PYTHONHOME"
  27. set -e _OLD_VIRTUAL_PYTHONHOME
  28. end
  29. if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
  30. and functions -q _old_fish_prompt
  31. # Set an empty local `$fish_function_path` to allow the removal of `fish_prompt` using `functions -e`.
  32. set -l fish_function_path
  33. # Erase virtualenv's `fish_prompt` and restore the original.
  34. functions -e fish_prompt
  35. functions -c _old_fish_prompt fish_prompt
  36. functions -e _old_fish_prompt
  37. set -e _OLD_FISH_PROMPT_OVERRIDE
  38. end
  39. set -e VIRTUAL_ENV
  40. if test "$argv[1]" != 'nondestructive'
  41. # Self-destruct!
  42. functions -e pydoc
  43. functions -e deactivate
  44. functions -e _bashify_path
  45. functions -e _fishify_path
  46. end
  47. end
  48. # Unset irrelevant variables.
  49. deactivate nondestructive
  50. set -gx VIRTUAL_ENV 'C:\Users\poliv\Desktop\RestApiPython\rest_api_venv'
  51. # https://github.com/fish-shell/fish-shell/issues/436 altered PATH handling
  52. if test (echo $FISH_VERSION | head -c 1) -lt 3
  53. set -gx _OLD_VIRTUAL_PATH (_bashify_path $PATH)
  54. else
  55. set -gx _OLD_VIRTUAL_PATH $PATH
  56. end
  57. set -gx PATH "$VIRTUAL_ENV"'/Scripts' $PATH
  58. # Unset `$PYTHONHOME` if set.
  59. if set -q PYTHONHOME
  60. set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
  61. set -e PYTHONHOME
  62. end
  63. function pydoc
  64. python -m pydoc $argv
  65. end
  66. if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
  67. # Copy the current `fish_prompt` function as `_old_fish_prompt`.
  68. functions -c fish_prompt _old_fish_prompt
  69. function fish_prompt
  70. # Run the user's prompt first; it might depend on (pipe)status.
  71. set -l prompt (_old_fish_prompt)
  72. # Prompt override provided?
  73. # If not, just prepend the environment name.
  74. if test -n ''
  75. printf '(%s) ' ''
  76. else
  77. printf '(%s) ' (basename "$VIRTUAL_ENV")
  78. end
  79. string join -- \n $prompt # handle multi-line prompts
  80. end
  81. set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
  82. end