You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 rivejä
1.5 KiB

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