Skip to content

Instantly share code, notes, and snippets.

@galaydaroman
Last active August 2, 2017 01:43
Show Gist options
  • Save galaydaroman/e0c3a4fbf422e76e22c6013d1dbdc16b to your computer and use it in GitHub Desktop.
Save galaydaroman/e0c3a4fbf422e76e22c6013d1dbdc16b to your computer and use it in GitHub Desktop.
chruby compatibility with RVM (injection in /usr/local/share/chruby/chruby.sh) and windows chruby
# require 'pry'
# binding.pry
linked_folder = 'C:\\Rails\\RubyCurrent'
rubies = {
'2.1' => 'C:\\Rails\\Ruby2.1.0',
'2.2' => 'C:\\Rails\\Ruby2.2.0'
}
current_version = RUBY_VERSION[/\d.\d/]
toggle_version = rubies.keys.reject {|v| v == current_version }.first
system "rmdir #{linked_folder}"
system %Q{mklink.bat "#{linked_folder}" "#{rubies[toggle_version]}"}
puts 'Switched ruby version to %s' % toggle_version
#!/usr/bin/env bash --login
source ~/.rvm/scripts/extras/chruby.sh
function chruby() {
echo "Skipping chruby!"
}
# detect `$rvm_path`
if [ -z "${rvm_path:-}" ] && [ -x "${HOME:-}/.rvm/bin/rvm" ]
then rvm_path="${HOME:-}/.rvm"
fi
if [ -z "${rvm_path:-}" ] && [ -x "/usr/local/rvm/bin/rvm" ]
then rvm_path="/usr/local/rvm"
fi
# load environment of current project ruby
if
[ -n "${rvm_path:-}" ] &&
[ -x "${rvm_path:-}/bin/rvm" ] &&
rvm_project_environment=`"${rvm_path:-}/bin/rvm" . do rvm env --path 2>/dev/null` &&
[ -n "${rvm_project_environment:-}" ] &&
[ -s "${rvm_project_environment:-}" ]
then
echo "RVM loading: ${rvm_project_environment:-}"
\. "${rvm_project_environment:-}"
else
echo "RVM project not found at: $PWD"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment