Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RVM showing Ruby version in ZSH

I just installed rvm to upgrade ruby using the method outlined here. After installation my zsh instance now always displays rvm:ruby-2.3.0, as per this image:

enter image description here

I'd rather it not appear but I'm having trouble finding where it's set, any thoughts? It's pretty annoying.

Thanks!

like image 461
bulletblue Avatar asked Aug 26 '16 15:08

bulletblue


People also ask

How do I change the default version of RVM?

Try running rvm --default 1.9. 2 instead. That works for me. Did you accidentally put the line to load rvm in your bashrc instead of your bash_profile ?

How do I use a specific version of ruby?

Selecting a version of Ruby You'll need to install bundler 1.2. x or above to use the ruby keyword and bundler 1.13. x or above to use a Ruby version specifier. You can use the ruby keyword in your app's Gemfile to specify a specific version of Ruby.


2 Answers

Your prompt is set in a .zsh-theme file that is specified in your .zshrc file in your home directory.

Changing to another theme:

If you want to change your prompt to a preexisting one, open your .zshrc file with your favorite text editor. Your can find your .zshrc in ~/.zshrc. When you open that file you will see a line that looks something like this: ZSH_THEME="gallois". (It looks like you're using gallois)

This is the line that you should change if you want to change your entire prompt. For example, change your this from ZSH_THEME="gallois" to ZSH_THEME="dallas" to change to the preexisting dallas theme. Click here For a list of all the default themes and what they look like. These themes are located in ~/.oh-my-zsh/themes.

You should then run . ~/.zshrc to source zsh and you will see the new prompt.

Editing the gallois theme to remove the right prompt

These themes are located in ~/.oh-my-zsh/themes. I would recommend copying the gallois.zsh-theme file and making some other file like yourname.zsh-theme. In the theme file you can remove the right prompt entirely by removing the line below this comment:

# Combine it all into a final right-side prompt
RPS1='$(git_custom_status)$(ruby_prompt_info) $EPS1'

You should probably remove this from the theme file as well for good measure:

# RVM component of prompt
ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[red]%}["
ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}"

#Customized git status, oh-my-zsh currently does not allow render dirty status before branch
git_custom_status() {
  local cb=$(git_current_branch)
  if [ -n "$cb" ]; then
    echo "$(parse_git_dirty)%{$fg_bold[yellow]%}$(work_in_progress)%{$reset_color%}$ZSH_THEME_GIT_PROMPT_PREFIX$(git_current_branch)$ZSH_THEME_GIT_PROMPT_SUFFIX"
  fi
}

Keep in mind, this will also remove any descriptions about git repos from your prompt. You should then run . ~/.zshrc to source zsh and you will see the new prompt.

Editing the gallois theme to only remove the ruby prompt

These themes are located in ~/.oh-my-zsh/themes. I would recommend copying the gallois.zsh-theme file and making some other file like yourname.zsh-theme. In the theme file you can remove just the rvm prompt by removing a portion of this line:

# Combine it all into a final right-side prompt
RPS1='$(git_custom_status)$(ruby_prompt_info) $EPS1'

If you just remove the $(ruby_prompt_info) portion so that it looks like this:

# Combine it all into a final right-side prompt
RPS1='$(git_custom_status) $EPS1'

Then you can skip to the end and only remove the rvm portion of the prompt. I would also recommend removing these lines to avoid cluttering the theme file:

# RVM component of prompt
ZSH_THEME_RVM_PROMPT_PREFIX="%{$fg[red]%}["
ZSH_THEME_RVM_PROMPT_SUFFIX="]%{$reset_color%}"

You should then run . ~/.zshrc to source zsh and you will see the new prompt.

like image 182
Caleb Adams Avatar answered Oct 13 '22 20:10

Caleb Adams


Another way to hide the ruby version information is to override the ruby_prompt_info() function used to determine what gets included in the prompt.

To do this, edit your ~/.zshrc and add the following after $HOME/.rvm/scripts/rvm has been sourced:

# hide ruby version from ps1
function ruby_prompt_info() { echo '' }
like image 41
Keith Hughitt Avatar answered Oct 13 '22 21:10

Keith Hughitt