25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

105 satır
1.6 KiB

  1. #!/usr/bin/env bash
  2. # Summary: Configure the shell environment for pyenv
  3. # Usage: eval "$(pyenv init - [--no-rehash] [<shell>])"
  4. set -e
  5. [ -n "$PYENV_DEBUG" ] && set -x
  6. print=""
  7. no_rehash=""
  8. for args in "$@"
  9. do
  10. if [ "$args" = "-" ]; then
  11. print=1
  12. shift
  13. fi
  14. if [ "$args" = "--no-rehash" ]; then
  15. no_rehash=1
  16. shift
  17. fi
  18. done
  19. shell="$1"
  20. if [ -z "$shell" ]; then
  21. shell="$(basename "$SHELL")"
  22. fi
  23. resolve_link() {
  24. $(type -p greadlink readlink | head -1) $1
  25. }
  26. abs_dirname() {
  27. local cwd="$(pwd)"
  28. local path="$1"
  29. while [ -n "$path" ]; do
  30. cd "${path%/*}"
  31. local name="${path##*/}"
  32. path="$(resolve_link "$name" || true)"
  33. done
  34. pwd
  35. cd "$cwd"
  36. }
  37. root="$(abs_dirname "$0")/.."
  38. if [ -z "$print" ]; then
  39. case "$shell" in
  40. bash )
  41. profile='~/.bash_profile'
  42. ;;
  43. zsh )
  44. profile='~/.zshrc'
  45. ;;
  46. ksh )
  47. profile='~/.profile'
  48. ;;
  49. * )
  50. profile='your profile'
  51. ;;
  52. esac
  53. { echo "# Load pyenv automatically by adding"
  54. echo "# the following to ${profile}:"
  55. echo
  56. echo 'eval "$(pyenv init -)"'
  57. echo
  58. } >&2
  59. exit 1
  60. fi
  61. mkdir -p "${PYENV_ROOT}/"{shims,versions}
  62. echo 'export PATH="'${PYENV_ROOT}'/shims:${PATH}"'
  63. case "$shell" in
  64. bash | zsh )
  65. echo "source \"$root/completions/pyenv.${shell}\""
  66. ;;
  67. esac
  68. if [ -z "$no_rehash" ]; then
  69. echo 'pyenv rehash 2>/dev/null'
  70. fi
  71. commands=(`pyenv-commands --sh`)
  72. IFS="|"
  73. cat <<EOS
  74. pyenv() {
  75. typeset command
  76. command="\$1"
  77. if [ "\$#" -gt 0 ]; then
  78. shift
  79. fi
  80. case "\$command" in
  81. ${commands[*]})
  82. eval \`pyenv "sh-\$command" "\$@"\`;;
  83. *)
  84. command pyenv "\$command" "\$@";;
  85. esac
  86. }
  87. EOS