我正在使用 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/