Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zsh & RVM woes (rvm-prompt doesn't resolve)

Tags:

zsh

rvm

zshrc

I recently saw the light and changed over to Zsh. I naturally used Oh My Zsh to configure it, as I'm noobish. So, there are several themes that have an rvm-prompt included and here is were my problems began. Everytime I load Zsh I have to rvm reload or else rvm-prompt is not resolved (zsh: command not found: rvm-prompt). Note that it resolves fine after I reload. Also, and in line, when I go to a directory that has its own .rvmrc (other gemset) and then I come out of it, the same problem occurs; I'm left with having to reload Zsh again. I have RVM in $PATH set. I have

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

in my .zshrc

I'm using the RVM plugin. Anybody know whats up? Not really a show stopper, just annoying.

like image 365
Wojtek Augustynski Avatar asked Jul 09 '11 16:07

Wojtek Augustynski


People also ask

What is zsh on Mac?

The Z shell (also known as zsh ) is a Unix shell that is built on top of bash (the default shell for macOS) with additional features. It's recommended to use zsh over bash . It's also highly recommended to install a framework with zsh as it makes dealing with configuration, plugins and themes a lot nicer.

Is zsh better than bash?

Zsh is more interactive and customizable than Bash. Zsh has floating-point support that Bash does not possess. Hash data structures are supported in Zsh that are not present in Bash. The invocation features in Bash is better when comparing with Zsh.

Is zsh installed on Mac?

If you're a regular Terminal user, you probably noticed that zsh is now the default shell in MacOS Terminal app (and yes you can change the shell to bash, tcsh, ksh, zsh, etc if you want to, but we're focusing on zsh, the default).

Is zsh faster than bash?

output and subshell The ksh and zsh seems about seven times faster than bash .


1 Answers

Make an alias to rvm-prompt. That's the most sure-fire answer. Arrange things in your .zshrc file in this order:

  1. alias rvm-prompt=$HOME/.rvm/bin/rvm-prompt
  2. source $ZSH/oh-my-zsh.sh
  3. [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

If oh-my-zsh (OMZ) loads before RVM, which rvm-prompt fails silently, so you won't see RVM in your prompt (if supported by your theme) even though it is in your path later, after RVM loads.

If RVM loads before OMZ, you may get a zsh: command not found: rvm-prompt.

Aliasing your rvm-prompt to its actual location seems to solve the problem, regardless of which order RVM and OMZ are loaded in. I'd still recommend RVM at the bottom.

Putting the RVM load into .zshenv as suggested above would load RVM twice in iTerm 2 (and no, it was not still in my .zshrc) and would result in the prompt displaying "system" even though rvm-prompt and rvm current showed a specific ruby version and gemset.

like image 140
jasongarber Avatar answered Oct 07 '22 12:10

jasongarber