Skip to content

Instantly share code, notes, and snippets.

@whargrove
Created December 18, 2014 22:41
Show Gist options
  • Save whargrove/fd5fb87cbb367b264836 to your computer and use it in GitHub Desktop.
Save whargrove/fd5fb87cbb367b264836 to your computer and use it in GitHub Desktop.
rbenv-installer
#!/usr/bin/env bash
# Verify Git is installed:
if [ ! $(which git) ]; then
echo "Git is not installed, can't continue."
exit 1
fi
if [ -z "${RBENV_ROOT}" ]; then
RBENV_ROOT="$HOME/.rbenv"
fi
# Install rbenv:
if [ ! -d "$RBENV_ROOT" ] ; then
git clone https://github.com/sstephenson/rbenv.git $RBENV_ROOT
else
cd $RBENV_ROOT
if [ ! -d '.git' ]; then
git init
git remote add origin https://github.com/sstephenson/rbenv.git
fi
git pull origin master
fi
# Install plugins:
PLUGINS=(
sstephenson/rbenv-vars
sstephenson/ruby-build
sstephenson/rbenv-default-gems
sstephenson/rbenv-gem-rehash
)
for plugin in ${PLUGINS[@]} ; do
KEY=${plugin%%/*}
VALUE=${plugin#*/}
RBENV_PLUGIN_ROOT="${RBENV_ROOT}/plugins/$VALUE"
if [ ! -d "$RBENV_PLUGIN_ROOT" ] ; then
git clone https://github.com/$KEY/$VALUE.git $RBENV_PLUGIN_ROOT
else
cd $RBENV_PLUGIN_ROOT
echo "Pulling $VALUE updates."
git pull
fi
done
# Show help if `.rbenv` is not in the path:
if [ ! $(which rbenv) ]; then
echo "
Seems you still have not added 'rbenv' to the load path:
# ~/.bash_profile:
export RBENV_ROOT=\"\${HOME}/.rbenv\"
if [ -d \"\${RBENV_ROOT}\" ]; then
export PATH=\"\${RBENV_ROOT}/bin:\${PATH}\"
eval \"\$(rbenv init -)\"
fi
"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment