Skip to content

Instantly share code, notes, and snippets.

@hmans hmans/gist:4492893
Last active Oct 7, 2016

Embed
What would you like to do?
A common environment variable for Ruby version switchers?

bash-it and ohmyzsh are two popular frameworks for extending the functionality of Bash and ZSH, respectively. One of their features is a built-in themeing system, and both implementations already try to integrate with some (but not all) Ruby version switchers to display the currently active Ruby as part of the shell prompt. At least in bash-it's case, this integration appears to have started out supporting RVM only, with support for rbenv and rbfu added later. This results in unfortunate code like this example.

We've recently agreed to use .ruby-version instead of switcher-specific files (.rbfu-version, .rbenv-version etc.), maybe we can also find a simple common name for an environment variable containing the currently selected Ruby (including patchlevel)?

Right now, the two alternatives I'm seeing are:

  1. Implementing switcher-specific code (what people have been doing so far)
  2. Grep the version from ruby -v (which would work, but may be a bit overkill to do)
  3. ...maybe there are more?

Thanks for your time and input.

@hmans

This comment has been minimized.

Copy link
Owner Author

commented Jan 9, 2013

I'm going to go ahead and summon @mpapis (RVM), @postmodern (chruby) and @sstephenson (rbenv) to this discussion. Sorry for disturbing. :)~

@nmeum

This comment has been minimized.

Copy link

commented Feb 23, 2013

Grep the version from ruby -v (which would work, but may be a bit overkill to do)

Well...using awk it isn't an overkill at all: ruby --version | awk '{print $2}'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.