Skip to content

Commit 826acc5

Browse files
authored
Use the new rbenv init to set up the user's shell (#50)
* Use the new `rbenv init` to set up the user's shell * Do not symlink `/opt/rubies` into rbenv versions This is because entries in `/opt/rubies` are typically prefixed with "ruby-", but rbenv does not use that prefix. Also, this is a feature of the installer literally no one asked for.
1 parent 3392664 commit 826acc5

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

bin/rbenv-installer

+20-22
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ else
4444
git remote add -f -t master origin https://github.com/rbenv/rbenv.git
4545
git checkout -b master origin/master
4646
rbenv=~/.rbenv/bin/rbenv
47-
48-
if [ ! -e versions ] && [ -w /opt/rubies ]; then
49-
ln -s /opt/rubies versions
50-
fi
5147
fi
5248
fi
5349

@@ -82,24 +78,26 @@ fi
8278
# Enable caching of rbenv-install downloads
8379
mkdir -p "${rbenv_root}/cache"
8480

81+
# Detect the type of shell that invoked the installer:
82+
shell="$(ps -p "$PPID" -o 'args=' 2>/dev/null || true)"
83+
shell="${shell%% *}"
84+
shell="${shell##-}"
85+
shell="${shell:-$SHELL}"
86+
shell="${shell##*/}"
87+
88+
case "$shell" in
89+
bash | zsh| ksh | ksh93 | mksh | fish )
90+
# allow known shells to be configured
91+
;;
92+
* )
93+
# default to bash in case the parent process is not a known shell
94+
shell=bash
95+
;;
96+
esac
97+
8598
echo
86-
echo "All done!"
87-
echo "Note that this installer does NOT edit your shell configuration files:"
88-
i=0
89-
rbenv_command="rbenv"
90-
if [ -x ~/.rbenv/bin ]; then
91-
# shellcheck disable=SC2088
92-
rbenv_command='~/.rbenv/bin/rbenv'
93-
fi
94-
echo "$((++i)). Run \`$rbenv_command init' to view instructions on how to configure rbenv for your shell."
95-
echo "$((++i)). Launch a new terminal window after editing shell configuration files."
99+
echo "Setting up your shell with \`rbenv init $shell' ..."
100+
"$rbenv" init "$shell"
96101

97-
url="https://github.com/rbenv/rbenv-installer/raw/HEAD/bin/rbenv-doctor"
98-
if false && type -p curl >/dev/null; then
99-
echo "$((++i)). (Optional) Run the doctor command to verify the installation:"
100-
printf ' curl -fsSL "%s" | bash\n' "$url"
101-
elif type -p wget >/dev/null; then
102-
echo "$((++i)). (Optional) Run the doctor command to verify the installation:"
103-
printf ' wget -q "%s" -O- | bash\n' "$url"
104-
fi
105102
echo
103+
echo "All done! After reloading your terminal window, rbenv should be good to go."

0 commit comments

Comments
 (0)