Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 877d4015009eb2a56b4570a627571ddef4b34fbf 0 parents
Konstantin Haase authored
Showing with 84 additions and 0 deletions.
  1. +47 −0 README.md
  2. +37 −0 bin/rbenv-sh-use
47 README.md
@@ -0,0 +1,47 @@
+This [rbenv](http://rbenv.org/) plugin allows easier switching between Ruby versions without having to keep patchlevels in mind.
+
+Pro tip: Alias `rbenv` to `rvm` to ease transition. The `--global` option is aliased to `--default` exactly for that purpose.
+
+## Usage examples
+
+Switch current shell to lates stable JRuby:
+
+ rbenv use jruby
+
+Switch to whatever would be default (global or local):
+
+ rbenv use default
+
+Make latest stable 1.9.3 global default and switch to using it:
+
+ rbenv use 1.9.3 --global
+
+Make whatever the current Ruby is the global default:
+
+ rbenv use current --global
+
+Make whatever the current Ruby is the local default:
+
+ rbenv use current --local
+
+Make whatever the local Ruby is the global default:
+
+ rbenv use local --global
+
+Use 2.0 development version:
+
+ rbenv use 2.0
+
+Use rbx development version:
+
+ rbenv use rbx
+
+## Installation
+
+Run these commands:
+
+ mkdir -p $RBENV_ROOT/plugins
+ git clone https://github.com/rkh/rbenv-whatis.git $RBENV_ROOT/plugins/rbenv-whatis
+ git clone https://github.com/rkh/rbenv-use.git $RBENV_ROOT/plugins/rbenv-use
+
+Skip the first `git clone` if you already installed [rbenv-whatis](https://github.com/rkh/rbenv-whatis).
37 bin/rbenv-sh-use
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+set -e
+[ -n "$RBENV_DEBUG" ] && set -x
+
+if ! which rbenv-whatis >/dev/null 2>&1; then
+ echo "rbenv-whatis plugin not installed, please run:" >&2
+ echo -e "\n\tgit clone https://github.com/rkh/rbenv-whatis.git $RBENV_ROOT/plugins/rbenv-whatis\n" >&2
+ exit 1
+fi
+
+case $# in
+ 1)
+ if [ $1 = default ]; then
+ _ruby=--unset
+ else
+ _ruby=$1
@timfel
timfel added a note

why not use $RBENV_VERSION? is that not the default variable anymore?

@rkh Owner
rkh added a note

This variable is just used internally. By using rbenv shell further down I do not rely on internals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ fi
+ _command=shell;;
+ 2)
+ _ruby=$1
+ case $2 in
+ --global|-g|--default|-d) _command=global;;
+ --shell|-s) _command=shell;;
+ --local|-l) _command=local;;
+ esac;;
+ *)
+ echo "usage: rbenv use NAME [OPTION]" >&2
+ exit 1;;
+esac
+
+_ruby=`command rbenv whatis $_ruby`
+
+if [ $_command = shell ]; then
+ echo `rbenv sh-shell $_ruby`
+else
+ echo "eval `rbenv sh-shell --unset` && command rbenv $_command $_ruby"
+fi
Please sign in to comment.
Something went wrong with that request. Please try again.