Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Modernize .rvmrc

  • Loading branch information...
commit 458d8daf460391d6bd7a8db685e628f944695ae0 1 parent 774ebda
@therubymug authored
Showing with 30 additions and 4 deletions.
  1. +30 −4 .rvmrc
View
34 .rvmrc
@@ -1,5 +1,31 @@
-if [[ -n "$rvm_path/environments" && -s "$rvm_path/environments/ruby-1.8.7-p302@hitch" ]] ; then
- \. "$rvm_path/environments/ruby-1.8.7-p302@hitch"
+#!/usr/bin/env bash
+
+# This is an RVM Project .rvmrc file, used to automatically load the ruby
+# development environment upon cd'ing into the directory
+
+# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
+environment_id="ruby-1.9.2-p290@hitch"
+
+#
+# First we attempt to load the desired environment directly from the environment
+# file. This is very fast and efficient compared to running through the entire
+# CLI and selector. If you want feedback on which environment was used then
+# insert the word 'use' after --create as this triggers verbose mode.
+#
+if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
+then
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
+
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
+ then
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
+ fi
else
- rvm --create use "ruby-1.8.7-p302@hitch"
-fi
+ # If the environment file has not yet been created, use the RVM CLI to select.
+ if ! rvm --create "$environment_id"
+ then
+ echo "Failed to create RVM environment '${environment_id}'."
+ exit 1
+ fi
+fi
Please sign in to comment.
Something went wrong with that request. Please try again.