Permalink
Browse files

Merge pull request #268 from CraigCottingham/rvmselect

Add scripts/functions/developer, from https://gist.github.com/984bd56424b
  • Loading branch information...
2 parents caa32fc + ceb70a0 commit b478c5c2b148fd09f0b4135822e1f3b16cbbaa3d @wayneeseguin wayneeseguin committed May 13, 2011
Showing with 40 additions and 0 deletions.
  1. +40 −0 scripts/functions/developer
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+
+#
+# Switch between RVM installs.
+# Given a topic context name like "testing", looks for a directory named ".rvm.testing"
+# (installing a new copy of RVM in it if it doesn't already exist), then symlinks
+# .rvm to it.
+#
+# rvmselect testing
+rvmselect()
+{
+ if [[ -z "${1:-}" ]]
+ then
+ echo "No topic context name specified (example: work )"
+ return 0
+ fi
+
+ local name=$1
+
+ true ${rvm_path:=$HOME/.rvm}
+
+ if [[ ! -L "$rvm_path" && -d "$rvm_path" ]]
+ then
+ printf "ERROR: $rvm_path is a directory, rename it to .<somename> first."
+ fi
+
+ if [[ ! -d "${rvm_path}.${name}" ]]
+ then
+ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
+ mv "${rvm_path}" "${rvm_path}.${name}"
+ fi
+
+ rm -f "${rvm_path}"
+
+ ln -fs "${rvm_path}.${name}" "${rvm_path}"
+
+ ls -al "$(basename "${rvm_path}")" | grep "$rvm_path" | awk '/rvm/{print "=> "$NF}'
+
+ return $?
+}

0 comments on commit b478c5c

Please sign in to comment.