Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I display RVM's current Ruby and gemset in the Terminal prompt?

Tags:

bash

ruby

rvm

I'm using rvm-prompt. It seems the interpreter, the version, the patchlevel, and the gemset should all displayed by default.

If I call the prompt, it accurately returns the current ruby and gemset:

$ rvm-prompt
ruby-1.8.7-p302@rails125

But my gemset isn't reflected in my prompt:

ruby-1.8.7-p302 MacBook:~ subpixel$ 

I tried calling the gemset explicitly in .bash_profile with:

PS1="\$(~/.rvm/bin/rvm-prompt i v p g) $PS1"

but it doesn't change the prompt.

like image 472
rda3000 Avatar asked Dec 01 '10 20:12

rda3000


1 Answers

If you look at the documentation for rvm-prompt, at the bottom of the page you'll find the following:

ps1_functions

Recently there has been a pair programming session that turned out a useful bit of prompt setting code. It now resides in contrib/ so you can require it in your profiles as follows after sourcing RVM itself.

source "$rvm_path/contrib/ps1_functions"

Immediately after that you can customize your prompt by adding the following line

ps1_set

There is an article and screen cast associated with this in the community resources section.

I copied the ps1_functions file, changed it to suit my needs and source that in my .bash_profile. Then I just have a line that calls

ps1_set

Now my prompt changes when I change gemsets

like image 163
Kris Robison Avatar answered Jan 01 '23 21:01

Kris Robison