Seems like you could tighten this up a bit:

```
        gempath = `gem env gempath`

        global_gemset = if (/rbenv/ =~ gempath)
          # for RBENV user
            gempath.split(":").first
        else
          # for RVM user
          ( ENV["GEM_PATH"] || `rvm $(rvm current) do gem env path`.chop ).split(':').grep(/ruby.*@global/).first
        end
```