7

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!

Community
  • 1
  • 1
bulletblue
  • 129
  • 1
  • 7

3 Answers3

10

If, like me, you ended up here because of this problem with the powerlevel10k theme, do the following:

  1. Open ~/.p10k.zsh

  2. Find the line:

    rvm                     # ruby version from rvm (https://rvm.io)
    
  3. Comment it out:

    # rvm                     # ruby version from rvm (https://rvm.io)
    
  4. Open a new terminal

kenny_k
  • 3,831
  • 5
  • 30
  • 41
  • my codespaces in github all of a sudden were showing the ruby version, so thanks for the pro tip here to comment this line out. – Josh Johanning Nov 18 '22 at 00:26
6

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.

Caleb Adams
  • 4,445
  • 1
  • 26
  • 26
  • if, like me, you were going nuts making changes to your theme file that were not reflected in the actual shell, check to see if your theme is being loaded from a `custom` folder instead of the `themes` folder. – esperluette Sep 25 '17 at 17:48
5

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 '' }
Keith Hughitt
  • 4,860
  • 5
  • 49
  • 54