Skip to content

Instantly share code, notes, and snippets.

@hmans
Last active October 7, 2016 13:54
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hmans/4492893 to your computer and use it in GitHub Desktop.
Save hmans/4492893 to your computer and use it in GitHub Desktop.
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
Copy link
Author

hmans 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
Copy link

nmeum 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