diff --git a/other_software/install_rbenv_and_ruby.sh b/other_software/install_rbenv_and_ruby.sh new file mode 100644 index 0000000..d19b1c7 --- /dev/null +++ b/other_software/install_rbenv_and_ruby.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# Install rbenv and ruby-build +echo "Installing rbenv and ruby-build..." +if ! command -v git &> /dev/null; then + echo "git is not installed. Please install git first." + exit 1 +fi + +if ! command -v curl &> /dev/null; then + echo "curl is not installed. Please install curl first." + exit 1 +fi + +git clone https://github.com/rbenv/rbenv.git ~/.rbenv +cd ~/.rbenv && src/configure && make -C src +echo "export PATH=\"\$HOME/.rbenv/bin:\$PATH\"" >> ~/.bashrc +echo "eval \"\$(rbenv init -)\"" >> ~/.bashrc +# shellcheck source=/dev/null +source ~/.bashrc + +git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build +echo "export PATH=\"\$HOME/.rbenv/plugins/ruby-build/bin:\$PATH\"" >> ~/.bashrc +# shellcheck source=/dev/null +source ~/.bashrc + +# Get the latest 5 Ruby versions +echo "Fetching latest Ruby versions..." +VERSIONS=$(rbenv install -l | grep -E "^\s*\d+\.\d+\.\d+$" | tail -n 5) + +# Present the user with options +echo "Please select a Ruby version to install:" +select VERSION in $VERSIONS; do + if [[ -n "$VERSION" ]]; then + echo "You selected $VERSION. Installing..." + rbenv install "$VERSION" + rbenv global "$VERSION" + echo "Ruby $VERSION installed and set as global version." + break + else + echo "Invalid selection. Please try again." + fi +done + +echo "Done!"