如何在终端提示中显示RVM当前的Ruby和gemset?

时间:2021-06-06 23:07:16

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

我正在使用rvm-prompt。看来解释器,版本,补丁级别和gemset都应默认显示。

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

如果我调用提示符,它会准确返回当前的ruby和gemset:

$ rvm-prompt
ruby-1.8.7-p302@rails125

But my gemset isn't reflected in my prompt:

但我的gemset没有反映在我的提示中:

ruby-1.8.7-p302 MacBook:~ subpixel$ 

I tried calling the gemset explicitly in .bash_profile with:

我尝试在.bash_profile中显式调用gemset:

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

but it doesn't change the prompt.

但它不会改变提示。

2 个解决方案

#1


5  

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

如果您查看rvm-prompt的文档,请在页面底部找到以下内容:

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.

最近出现了一对编程会话,结果显示了一些有用的提示设置代码。它现在位于contrib /中,因此您可以在获取RVM本身之后在您的配置文件中按要求进行操作。

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_functions文件,更改了它以满足我的需要并在我的.bash_profile中找到它。然后我只有一个电话线

ps1_set

Now my prompt changes when I change gemsets

现在,当我更改gemsets时,我的提示会发生变化

#2


0  

You might have discovered a bug, because I see the same behavior. I'd recommend running it past RVM's author. You can find his email address by running rvm -v.

您可能已经发现了一个错误,因为我看到了相同的行为。我建议通过RVM的作者运行它。您可以通过运行rvm -v找到他的电子邮件地址。

#1


5  

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

如果您查看rvm-prompt的文档,请在页面底部找到以下内容:

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.

最近出现了一对编程会话,结果显示了一些有用的提示设置代码。它现在位于contrib /中,因此您可以在获取RVM本身之后在您的配置文件中按要求进行操作。

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_functions文件,更改了它以满足我的需要并在我的.bash_profile中找到它。然后我只有一个电话线

ps1_set

Now my prompt changes when I change gemsets

现在,当我更改gemsets时,我的提示会发生变化

#2


0  

You might have discovered a bug, because I see the same behavior. I'd recommend running it past RVM's author. You can find his email address by running rvm -v.

您可能已经发现了一个错误,因为我看到了相同的行为。我建议通过RVM的作者运行它。您可以通过运行rvm -v找到他的电子邮件地址。