Skip to content

Commit

Permalink
adding rbenv support to all the rvm themes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brent Faulkner committed Jan 24, 2012
1 parent ac910b8 commit 6496acf
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 18 deletions.
10 changes: 8 additions & 2 deletions themes/alanpeabody.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@

local user='%{$fg[magenta]%}%n@%{$fg[magenta]%}%m%{$reset_color%}'
local pwd='%{$fg[blue]%}%~%{$reset_color%}'
local rvm='%{$fg[green]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
local rvm=''
if which rvm-prompt &> /dev/null; then
rvm='%{$fg[green]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
else
if which rbenv &> /dev/null; then
rvm='%{$fg[green]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
fi
fi
local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)%{$reset_color%}'

Expand All @@ -19,4 +26,3 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"

PROMPT="${user} ${pwd}$ "
RPROMPT="${return_code} ${git_branch} ${rvm}"

9 changes: 8 additions & 1 deletion themes/bira.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"

local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
local rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
else
if which rbenv &> /dev/null; then
rvm_ruby='%{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
fi
fi
local git_branch='$(git_prompt_info)%{$reset_color%}'

PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
Expand Down
8 changes: 7 additions & 1 deletion themes/crunch.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ ZSH_THEME_GIT_PROMPT_DIRTY=" $CRUNCH_GIT_DIRTY_COLOR✗"

# Our elements:
CRUNCH_TIME_="$CRUNCH_BRACKET_COLOR{$CRUNCH_TIME_COLOR%T$CRUNCH_BRACKET_COLOR}%{$reset_color%}"
CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(~/.rvm/bin/rvm-prompt i v g)#ruby-}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
if which rvm-prompt &> /dev/null; then
CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(~/.rvm/bin/rvm-prompt i v g)#ruby-}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
else
if which rbenv &> /dev/null; then
CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(rbenv version | sed -e 's/ (set.*$//' -e 's/^ruby-//')}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
fi
fi
CRUNCH_DIR_="$CRUNCH_DIR_COLOR%~\$(git_prompt_info) "
CRUNCH_PROMPT="$CRUNCH_BRACKET_COLOR"

Expand Down
8 changes: 7 additions & 1 deletion themes/dallas.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
# Grab the current date (%D) and time (%T) wrapped in {}: {%D %T}
DALLAS_CURRENT_TIME_="%{$fg[white]%}{%{$fg[yellow]%}%D %T%{$fg[white]%}}%{$reset_color%}"
# Grab the current version of ruby in use (via RVM): [ruby-1.8.7]
DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
if which rvm-prompt &> /dev/null; then
DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
else
if which rbenv &> /dev/null; then
DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}"
fi
fi
# Grab the current machine name: muscato
DALLAS_CURRENT_MACH_="%{$fg[green]%}%m%{$fg[white]%}:%{$reset_color%}"
# Grab the current filepath, use shortcuts: ~/Desktop
Expand Down
4 changes: 4 additions & 0 deletions themes/eastwood.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#RVM settings
if [[ -s ~/.rvm/scripts/rvm ]] ; then
RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1"
else
if which rbenv &> /dev/null; then
RPS1="%{$fg[yellow]%}rbenv:%{$reset_color%}%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$reset_color%} $EPS1"
fi
fi

ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
Expand Down
9 changes: 8 additions & 1 deletion themes/fino.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ function box_name {
}


local rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}'
local rvm_ruby=''
if which rvm-prompt &> /dev/null; then
rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}'
else
if which rbenv &> /dev/null; then
rvm_ruby='‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
fi
fi
local current_dir='${PWD/#$HOME/~}'
local git_info='$(git_prompt_info)'

Expand Down
6 changes: 5 additions & 1 deletion themes/gallois.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ git_custom_status() {
if [[ -s ~/.rvm/scripts/rvm ]] ; then
RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1'
else
RPS1='$(git_custom_status) $EPS1'
if which rbenv &> /dev/null; then
RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1'
else
RPS1='$(git_custom_status) $EPS1'
fi
fi

PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
4 changes: 2 additions & 2 deletions themes/jonathan.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function theme_precmd {
PR_PWDLEN=""

local promptsize=${#${(%):---(%n@%m:%l)---()--}}
local rubyprompt=`rvm_prompt_info`
local rubyprompt=`rvm_prompt_info || rbenv_prompt_info`
local rubypromptsize=${#${rubyprompt}}
local pwdsize=${#${(%):-%~}}

Expand Down Expand Up @@ -113,7 +113,7 @@ setprompt () {
PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
$PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_HBAR$PR_SHIFT_OUT$PR_GREY(\
$PR_GREEN%$PR_PWDLEN<...<%~%<<\
$PR_GREY)`rvm_prompt_info`$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}$PR_HBAR$PR_SHIFT_OUT$PR_GREY(\
$PR_GREY)`rvm_prompt_info || rbenv_prompt_info`$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}$PR_HBAR$PR_SHIFT_OUT$PR_GREY(\
$PR_CYAN%(!.%SROOT%s.%n)$PR_GREY@$PR_GREEN%m:%l\
$PR_GREY)$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_URCORNER$PR_SHIFT_OUT\
Expand Down
4 changes: 2 additions & 2 deletions themes/josh.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function josh_prompt {
prompt=" "

branch=$(current_branch)
ruby_version=$(rvm_prompt_info)
ruby_version=$(rvm_prompt_info || rbenv_prompt_info)
path_size=${#PWD}
branch_size=${#branch}
ruby_size=${#ruby_version}
Expand All @@ -31,7 +31,7 @@ function josh_prompt {
prompt=" $prompt"
done

prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info)%{$reset_color%} $(git_prompt_info)"
prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(git_prompt_info)"

echo $prompt
}
Expand Down
9 changes: 8 additions & 1 deletion themes/macovsky-ruby.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"

PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
if which rvm-prompt &> /dev/null; then
PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
else
if which rbenv &> /dev/null; then
PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
fi
fi

RPS1="${return_code}"

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
Expand Down
8 changes: 7 additions & 1 deletion themes/macovsky.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
# ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"

PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
if which rvm-prompt &> /dev/null; then
PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
else
if which rbenv &> /dev/null; then
PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
fi
fi
RPS1="${return_code}"

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
Expand Down
2 changes: 1 addition & 1 deletion themes/murilasso.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
local current_dir='%{$terminfo[bold]$fg[blue]%}%~%{$reset_color%}'
local rvm_ruby='%{$fg[red]%}$(rvm_prompt_info)%{$reset_color%}'
local rvm_ruby='%{$fg[red]%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%}'
local git_branch='%{$fg[blue]%}$(git_prompt_info)%{$reset_color%}'

PROMPT="${user_host}:${current_dir} ${rvm_ruby}
Expand Down
4 changes: 4 additions & 0 deletions themes/nebirhos.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# Get the current ruby version in use with RVM:
if [ -e ~/.rvm/bin/rvm-prompt ]; then
RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%})%{$reset_color%} "
else
if which rbenv &> /dev/null; then
RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg_bold[blue]%})%{$reset_color%} "
fi
fi

# Get the host name (first 4 chars)
Expand Down
8 changes: 7 additions & 1 deletion themes/superjarin.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Grab the current version of ruby in use (via RVM): [ruby-1.8.7]
JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
if which rvm-prompt &> /dev/null; then
JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
else
if which rbenv &> /dev/null; then
JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}"
fi
fi

# Grab the current filepath, use shortcuts: ~/Desktop
# Append the current git branch, if in a git repository
Expand Down
9 changes: 8 additions & 1 deletion themes/suvash.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,15 @@ function collapse_pwd {
echo $(pwd | sed -e "s,^$HOME,~,")
}

PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) using %{$reset_color%}%{$fg[red]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%}
if which rvm-prompt &> /dev/null; then
PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) using %{$reset_color%}%{$fg[red]%}$(~/.rvm/bin/rvm-prompt)%{$reset_color%}
$(virtualenv_info)$(prompt_char) '
else
if which rbenv &> /dev/null; then
PROMPT='%{$fg[magenta]%}%n%{$reset_color%} at %{$fg[yellow]%}%m%{$reset_color%} in %{$fg_bold[green]%}${PWD/#$HOME/~}%{$reset_color%}$(git_prompt_info) using %{$reset_color%}%{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//")%{$reset_color%}
$(virtualenv_info)$(prompt_char) '
fi
fi


ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
Expand Down
2 changes: 1 addition & 1 deletion themes/wuffers.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}["
ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%} x%{$fg_bold[blue]%}"

PROMPT='%{$(git_prompt_info)%}%{$fg_bold[green]%}{%{$(rvm current)%}}%{$reset_color%} %{$fg[cyan]%}%c%{$reset_color%} '
PROMPT='%{$(git_prompt_info)%}%{$fg_bold[green]%}{%{$(rvm current 2>/dev/null || rbenv version-name 2>/dev/null)%}}%{$reset_color%} %{$fg[cyan]%}%c%{$reset_color%} '
10 changes: 9 additions & 1 deletion themes/zhann.zsh-theme
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
PROMPT='%{$fg_bold[green]%}%p %{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
RPROMPT='%{$reset_color%} %{$fg[red]%}$(~/.rvm/bin/rvm-prompt i v g) %{$reset_color%}'

if which rvm-prompt &> /dev/null; then
RPROMPT='%{$reset_color%} %{$fg[red]%}$(~/.rvm/bin/rvm-prompt i v g) %{$reset_color%}'
else
if which rbenv &> /dev/null; then
RPROMPT='%{$reset_color%} %{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//") %{$reset_color%}'
fi
fi


ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
Expand Down

14 comments on commit 6496acf

@orip
Copy link

@orip orip commented on 6496acf Feb 6, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of these themes used to work without using rvm (or rbenv or the rbenv plugin) at all, because the ruby path string was just an empty string.
Now they fail with #878:

command not found: rbenv_prompt_info

Perhaps provide an empty rbenv_prompt_info using something like this?

functions rbenv_prompt_info >& /dev/null || rbenv_prompt_info() {}

@sbfaulkner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've submitted pull request #922 with a fix for this

@jarinudom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried your fix from pull request #922 and it still doesn't work (at least with the superjarin theme).

If I comment out the changes, it works. Would it be better to replace the RVM test with:

if [ -e ~/.rvm/bin/rvm-prompt ]; then

@jarinudom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just tried it with if [ -e ~/.rvm/bin/rvm-prompt ]; then and it works for me. I don't have rbenv installed, so I don't know if that part works.

@sbfaulkner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does "it still doesn't work" mean? when I try it on my machine it seems fine... what is the result and what is the expected result?

@jarinudom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shows the prompt:

~ 

Instead of the expected prompt:

[ruby-1.8.7] ~ 

Using the alternative test for rvm-prompt's existence fixed it.

@sbfaulkner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but, I'm a bit confused by description of the problem. When I comment out the code that I added, ie. so all that's there is the original JARIN_CURRENT_RUBY_="..." line, I get the following (provided that rvm is not available)...

zsh: no such file or directory: /Users/brent.faulkner/.rvm/bin/rvm-prompt                                                         
[] ~ 

What plugins do you have enabled? and do you have rvm installed or not? (it's good you have a workaround, but I want to look at the larger issue and make sure it gets fixed properly everywhere)

@sbfaulkner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw... the pull request #922 was to fix a slightly different problem (if I understand yours correctly), the problem reported by @orip was command not found: rbenv_prompt_info, while yours seems rvm-related

that said, it would be good to fix this one too, so let me know regarding the above-asked questions...

cheers

@jarinudom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes I used the solution from nebirhos.zsh-theme. Instead of if which rvm-prompt &> /dev/null; then I used if [ -e ~/.rvm/bin/rvm-prompt ]; then and it works for me.

I do have RVM installed, and here are the plugins I'm using:

plugins=(rails git git-flow textmate ruby brew gem mysql)

I think that the problem might be that which rvm-prompt &> /dev/null is returning false even if you have RVM installed, which is causing it to skip down to the rbenv section. Can you try using if [ -e ~/.rvm/bin/rvm-prompt ]; then and see if that works?

@sbfaulkner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated pull request #922 to include an extra commit that should address this

cheers

@jarinudom
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks :)

@JDutil
Copy link

@JDutil JDutil commented on 6496acf Feb 22, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbfaulkner your fix in #922 didn't address all of the themes that were originally edited so I've opened #964 to fix the others I found that needed to be updated with the fix, which did fix the theme I was using.

@sbfaulkner
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, the problem you're fixing, while very similar is not quite the same... the ones that I fixed were the ones that had hard-coded paths - you are fixing the ones that assume that rvm-prompt is in the path

that said, I appreciate the fact that you are actually providing a fix (rather than just reporting the problem :-)

@JDutil
Copy link

@JDutil JDutil commented on 6496acf Feb 22, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my bad well I didn't read through everything going on here so that's what I get for assuming. Regardless I was having an issue with the theme I was using that was related to this change, and implementing the fix you had done for the other themes fixed my theme as well.

Please sign in to comment.