How to make fish shell use rvm ruby ​​by default

I am using shell 2.10 for Mac OS X 10.9.1. I would like to use Ruby, which I set using RVM as the default value in my terminals, however I cannot do this work.

I tried rvm use 2.1.0 --default , but when I open a new terminal, I still get the following:

 > which ruby /usr/bin/ruby 

Running the rvm causes the ruby ​​to load:

 > which ruby /usr/bin/ruby > rvm [...] > which ruby /Users/alex/.rvm/rubies/ruby-2.1.0/bin/ruby 

But it is annoying to do this every time I open a new terminal.

+7
ruby fish rvm macos
source share
6 answers

First install the rvm fish functions from rvm.io

 curl -L --create-dirs -o ~/.config/fish/functions/rvm.fish https://raw.github.com/lunks/fish-nuggets/master/functions/rvm.fish 

Now you can use the rvm command in fish after re-opening the terminal.

Follow the rvm default to add the rvm default line to the fish configuration file.

 echo 'rvm default' >> ~/.config/fish/config.fish 

Now you can use binary files and gems associated with ruby ​​after re-opening the terminal.

+18
source share

Install oh-my-fish very useful tools, you have the rvm plugin and many others.

Framework for managing your fish’s configuration

+5
source share

I think to make this easier, you can add the rvm plugin to the fish shell with fisher .

To install the phisher:

 curl -Lo ~/.config/fish/functions/fisher.fish --create-dirs git.io/fisher 

After that install the rvm plugin for Fish Shell:

 fisher add jorgebucaran/fish-nvm 

After that, rvm works fine.

(formerly fisher rvm )

+5
source share

This below worked for me from the google group forum. eggegg loan for this solution below:

The original fish shell support requires converting a bash script to a fish script. As mentioned here: https://rvm.io/integration/fish .

I found a simpler solution there: let bash execute bash scripts, we only need the result of environment variables.

code: https://gist.github.com/eggegg/6077153

Just paste the first into your own config.fish, then copy rvm.fish to ~ / .config / fish / functions / by doing the tricks.

0
source share

This is because out of the box Ruby installed through RVM are not added to your path. When you run any RVM command, it adds the paths to the ruby ​​version you are using to $ PATH. RVM seems to care about bash and zsh, but does not have built-in support to fix the paths for your point files.

Here is an example of my path before the RVM command:

 /Users/grant/pear/bin /usr/local/sbin/ /Users/grant/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/git/bin /usr/local/go/bin 

Here is an example of my path after running 'rvm':

 /Users/grant/.rvm/gems/ruby-2.2.0/bin /Users/grant/.rvm/gems/ ruby-2.2.0@global /bin /Users/grant/.rvm/rubies/ruby-2.2.0/bin /Users/grant/pear/bin /usr/local/sbin/ /Users/grant/.rvm/bin /usr/local/bin /usr/bin /bin /usr/sbin /sbin /usr/local/git/bin /usr/local/go/bin 

The bottom line is that you will want to add .rvm files to your path depending on the version by default of which you are by default. This post helped me figure out how to do this. You can add the paths that RVM adds to your fish profile:

 set -g -x PATH $PATH <paths_to_add> 

Example above:

 set -g -x PATH $PATH /Users/grant/.rvm/gems/ruby-2.2.0/bin /Users/grant/.rvm/gems/ ruby-2.2.0@global /bin /Users/grant/.rvm/rubies/ruby-2.2.0/bin 

To have this run every time you load the fish, add the above command to ~ / .config / fish / config.fish. Alternatively, you can add the rvm command to your fish configuration and download it for you.

Hope this helps! -Grant

0
source share

In your config.fish boot plugin and call it silently:

. ~/oh-my-fish/plugins/rvm/rvm rvm >/dev/null

If you use the bob-the-fish theme, you will have a ruby ​​version in your invitation:

ruby-2.1.2 > ~/d/web > master >

What can be suppressed if you want by deleting the line below in the bobthefish / fish_prompt.fish file:

__bobthefish_prompt_rubies

0
source share

All Articles