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

标签 ruby bash rvm

我正在使用 rvm-prompt .似乎解释器、版本、补丁级别和 gemset 都应该默认显示。

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

$ rvm-prompt
ruby-1.8.7-p302@rails125

但是我的 gemset 没有反射(reflect)在我的提示中:

ruby-1.8.7-p302 MacBook:~ subpixel$ 

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

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

但它不会更改提示。

最佳答案

如果您查看 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.

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.

我复制了 ps1_functions 文件,对其进行了更改以满足我的需要,并在我的 .bash_profile 中获取了该文件。然后我只有一行调用

ps1_set

现在当我更改 gemsets 时我的提示会改变

关于ruby - 如何在终端提示中显示 RVM 当前的 Ruby 和 gemset?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4328538/

相关文章:

bash - 统计文件最快的方法是什么?

bash - 区分两个流(使用 fifo)直到一个结束——只适用于短流

rvm - 在/usr/local/rvm/scripts/rvm安装rvm出错

git hook 来测试文件是否包含正确的数据

ruby - 运行错误 '__rvm_make -j 1'

ruby-on-rails - 在 Ubuntu 12.04 中卸载 RVM、Ruby、Ruby gem 和 Rails

ruby - Ruby 数组是什么数据结构?

ruby-on-rails - Ruby SSL 握手未收到服务器 Hello 返回 - 使用代理 Net::HTTP

ruby-on-rails - 用于 Ruby on Rails 的 SAML 2.0 SSO?

ruby - 获取 Facebook 好友的位置非常耗时