Browse code

adding rbenv support to all the rvm themes

Brent Faulkner authored on 24/01/2012 at 01:42:54
Showing 17 changed files
... ...
@@ -1,7 +1,14 @@
1 1
 
2 2
 local user='%{$fg[magenta]%}%n@%{$fg[magenta]%}%m%{$reset_color%}'
3 3
 local pwd='%{$fg[blue]%}%~%{$reset_color%}'
4
-local rvm='%{$fg[green]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
4
+local rvm=''
5
+if which rvm-prompt &> /dev/null; then
6
+  rvm='%{$fg[green]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
7
+else
8
+  if which rbenv &> /dev/null; then
9
+    rvm='%{$fg[green]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
10
+  fi
11
+fi
5 12
 local return_code='%(?..%{$fg[red]%}%? ↵%{$reset_color%})'
6 13
 local git_branch='$(git_prompt_status)%{$reset_color%}$(git_prompt_info)%{$reset_color%}'
7 14
 
... ...
@@ -19,4 +26,3 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%{$fg[cyan]%} ✭"
19 19
 
20 20
 PROMPT="${user} ${pwd}$ "
21 21
 RPROMPT="${return_code} ${git_branch} ${rvm}"
22
-
... ...
@@ -3,7 +3,14 @@ local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
3 3
 
4 4
 local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
5 5
 local current_dir='%{$terminfo[bold]$fg[blue]%} %~%{$reset_color%}'
6
-local rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
6
+local rvm_ruby=''
7
+if which rvm-prompt &> /dev/null; then
8
+  rvm_ruby='%{$fg[red]%}‹$(rvm-prompt i v g)›%{$reset_color%}'
9
+else
10
+  if which rbenv &> /dev/null; then
11
+    rvm_ruby='%{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
12
+  fi
13
+fi
7 14
 local git_branch='$(git_prompt_info)%{$reset_color%}'
8 15
 
9 16
 PROMPT="╭─${user_host} ${current_dir} ${rvm_ruby} ${git_branch}
... ...
@@ -29,7 +29,13 @@ ZSH_THEME_GIT_PROMPT_DIRTY=" $CRUNCH_GIT_DIRTY_COLOR✗"
29 29
 
30 30
 # Our elements:
31 31
 CRUNCH_TIME_="$CRUNCH_BRACKET_COLOR{$CRUNCH_TIME_COLOR%T$CRUNCH_BRACKET_COLOR}%{$reset_color%}"
32
-CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(~/.rvm/bin/rvm-prompt i v g)#ruby-}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
32
+if which rvm-prompt &> /dev/null; then
33
+  CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(~/.rvm/bin/rvm-prompt i v g)#ruby-}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
34
+else
35
+  if which rbenv &> /dev/null; then
36
+    CRUNCH_RVM_="$CRUNCH_BRACKET_COLOR"["$CRUNCH_RVM_COLOR\${\$(rbenv version | sed -e 's/ (set.*$//' -e 's/^ruby-//')}$CRUNCH_BRACKET_COLOR"]"%{$reset_color%}"
37
+  fi
38
+fi
33 39
 CRUNCH_DIR_="$CRUNCH_DIR_COLOR%~\$(git_prompt_info) "
34 40
 CRUNCH_PROMPT="$CRUNCH_BRACKET_COLOR➭ "
35 41
 
... ...
@@ -3,7 +3,13 @@
3 3
 # Grab the current date (%D) and time (%T) wrapped in {}: {%D %T}
4 4
 DALLAS_CURRENT_TIME_="%{$fg[white]%}{%{$fg[yellow]%}%D %T%{$fg[white]%}}%{$reset_color%}"
5 5
 # Grab the current version of ruby in use (via RVM): [ruby-1.8.7]
6
-DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
6
+if which rvm-prompt &> /dev/null; then
7
+  DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
8
+else
9
+  if which rbenv &> /dev/null; then
10
+    DALLAS_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[magenta]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}"
11
+  fi
12
+fi
7 13
 # Grab the current machine name: muscato
8 14
 DALLAS_CURRENT_MACH_="%{$fg[green]%}%m%{$fg[white]%}:%{$reset_color%}"
9 15
 # Grab the current filepath, use shortcuts: ~/Desktop
... ...
@@ -1,6 +1,10 @@
1 1
 #RVM settings
2 2
 if [[ -s ~/.rvm/scripts/rvm ]] ; then 
3 3
   RPS1="%{$fg[yellow]%}rvm:%{$reset_color%}%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt)%{$reset_color%} $EPS1"
4
+else
5
+  if which rbenv &> /dev/null; then
6
+    RPS1="%{$fg[yellow]%}rbenv:%{$reset_color%}%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$reset_color%} $EPS1"
7
+  fi
4 8
 fi
5 9
 
6 10
 ZSH_THEME_GIT_PROMPT_PREFIX="%{$reset_color%}%{$fg[green]%}["
... ...
@@ -25,7 +25,14 @@ function box_name {
25 25
 }
26 26
 
27 27
 
28
-local rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}'
28
+local rvm_ruby=''
29
+if which rvm-prompt &> /dev/null; then
30
+  rvm_ruby='‹$(rvm-prompt i v g)›%{$reset_color%}'
31
+else
32
+  if which rbenv &> /dev/null; then
33
+    rvm_ruby='‹$(rbenv version | sed -e "s/ (set.*$//")›%{$reset_color%}'
34
+  fi
35
+fi
29 36
 local current_dir='${PWD/#$HOME/~}'
30 37
 local git_info='$(git_prompt_info)'
31 38
 
... ...
@@ -15,7 +15,11 @@ git_custom_status() {
15 15
 if [[ -s ~/.rvm/scripts/rvm ]] ; then 
16 16
   RPS1='$(git_custom_status)%{$fg[red]%}[`~/.rvm/bin/rvm-prompt`]%{$reset_color%} $EPS1'
17 17
 else
18
-  RPS1='$(git_custom_status) $EPS1'
18
+  if which rbenv &> /dev/null; then
19
+    RPS1='$(git_custom_status)%{$fg[red]%}[`rbenv version | sed -e "s/ (set.*$//"`]%{$reset_color%} $EPS1'
20
+  else
21
+    RPS1='$(git_custom_status) $EPS1'
22
+  fi
19 23
 fi
20 24
 
21 25
 PROMPT='%{$fg[cyan]%}[%~% ]%(?.%{$fg[green]%}.%{$fg[red]%})%B$%b '
... ...
@@ -10,7 +10,7 @@ function theme_precmd {
10 10
     PR_PWDLEN=""
11 11
 
12 12
     local promptsize=${#${(%):---(%n@%m:%l)---()--}}
13
-    local rubyprompt=`rvm_prompt_info`
13
+    local rubyprompt=`rvm_prompt_info || rbenv_prompt_info`
14 14
     local rubypromptsize=${#${rubyprompt}}
15 15
     local pwdsize=${#${(%):-%~}}
16 16
 
... ...
@@ -113,7 +113,7 @@ setprompt () {
113 113
     PROMPT='$PR_SET_CHARSET$PR_STITLE${(e)PR_TITLEBAR}\
114 114
 $PR_CYAN$PR_SHIFT_IN$PR_ULCORNER$PR_HBAR$PR_SHIFT_OUT$PR_GREY(\
115 115
 $PR_GREEN%$PR_PWDLEN<...<%~%<<\
116
-$PR_GREY)`rvm_prompt_info`$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_HBAR${(e)PR_FILLBAR}$PR_HBAR$PR_SHIFT_OUT$PR_GREY(\
116
+$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(\
117 117
 $PR_CYAN%(!.%SROOT%s.%n)$PR_GREY@$PR_GREEN%m:%l\
118 118
 $PR_GREY)$PR_CYAN$PR_SHIFT_IN$PR_HBAR$PR_URCORNER$PR_SHIFT_OUT\
119 119
 
... ...
@@ -10,7 +10,7 @@ function josh_prompt {
10 10
   prompt=" "
11 11
 
12 12
   branch=$(current_branch)
13
-  ruby_version=$(rvm_prompt_info)
13
+  ruby_version=$(rvm_prompt_info || rbenv_prompt_info)
14 14
   path_size=${#PWD}
15 15
   branch_size=${#branch}
16 16
   ruby_size=${#ruby_version}
... ...
@@ -31,7 +31,7 @@ function josh_prompt {
31 31
     prompt=" $prompt"
32 32
   done
33 33
   
34
-  prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info)%{$reset_color%} $(git_prompt_info)"
34
+  prompt="%{%F{green}%}$PWD$prompt%{%F{red}%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%} $(git_prompt_info)"
35 35
   
36 36
   echo $prompt
37 37
 }
... ...
@@ -1,7 +1,14 @@
1 1
 # ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
2 2
 local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
3 3
 
4
-PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
4
+if which rvm-prompt &> /dev/null; then
5
+  PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
6
+else
7
+  if which rbenv &> /dev/null; then
8
+    PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
9
+  fi
10
+fi
11
+
5 12
 RPS1="${return_code}"
6 13
 
7 14
 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
... ...
@@ -1,7 +1,13 @@
1 1
 # ZSH Theme - Preview: http://gyazo.com/8becc8a7ed5ab54a0262a470555c3eed.png
2 2
 local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
3 3
 
4
-PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
4
+if which rvm-prompt &> /dev/null; then
5
+  PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(~/.rvm/bin/rvm-prompt i v)› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
6
+else
7
+  if which rbenv &> /dev/null; then
8
+    PROMPT='%{$fg[green]%}%~%{$reset_color%} %{$fg[red]%}‹$(rbenv version | sed -e "s/ (set.*$//")› %{$reset_color%} $(git_prompt_info)%{$reset_color%}%B$%b '
9
+  fi
10
+fi
5 11
 RPS1="${return_code}"
6 12
 
7 13
 ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}‹"
... ...
@@ -1,7 +1,7 @@
1 1
 local return_code="%(?..%{$fg[red]%}%? ↵%{$reset_color%})"
2 2
 local user_host='%{$terminfo[bold]$fg[green]%}%n@%m%{$reset_color%}'
3 3
 local current_dir='%{$terminfo[bold]$fg[blue]%}%~%{$reset_color%}'
4
-local rvm_ruby='%{$fg[red]%}$(rvm_prompt_info)%{$reset_color%}'
4
+local rvm_ruby='%{$fg[red]%}$(rvm_prompt_info || rbenv_prompt_info)%{$reset_color%}'
5 5
 local git_branch='%{$fg[blue]%}$(git_prompt_info)%{$reset_color%}'
6 6
 
7 7
 PROMPT="${user_host}:${current_dir} ${rvm_ruby}
... ...
@@ -4,6 +4,10 @@
4 4
 # Get the current ruby version in use with RVM:
5 5
 if [ -e ~/.rvm/bin/rvm-prompt ]; then
6 6
     RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(~/.rvm/bin/rvm-prompt s i v g)%{$fg_bold[blue]%})%{$reset_color%} "
7
+else
8
+  if which rbenv &> /dev/null; then
9
+    RUBY_PROMPT_="%{$fg_bold[blue]%}rvm:(%{$fg[green]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg_bold[blue]%})%{$reset_color%} "
10
+  fi
7 11
 fi
8 12
 
9 13
 # Get the host name (first 4 chars)
... ...
@@ -1,5 +1,11 @@
1 1
 # Grab the current version of ruby in use (via RVM): [ruby-1.8.7]
2
-JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
2
+if which rvm-prompt &> /dev/null; then
3
+  JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(~/.rvm/bin/rvm-prompt i v)%{$fg[white]%}]%{$reset_color%}"
4
+else
5
+  if which rbenv &> /dev/null; then
6
+    JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}\$(rbenv version | sed -e 's/ (set.*$//')%{$fg[white]%}]%{$reset_color%}"
7
+  fi
8
+fi
3 9
 
4 10
 # Grab the current filepath, use shortcuts: ~/Desktop
5 11
 # Append the current git branch, if in a git repository
... ...
@@ -12,8 +12,15 @@ function collapse_pwd {
12 12
     echo $(pwd | sed -e "s,^$HOME,~,")
13 13
 }
14 14
 
15
-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%} 
15
+if which rvm-prompt &> /dev/null; then
16
+  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%} 
16 17
 $(virtualenv_info)$(prompt_char) '
18
+else
19
+  if which rbenv &> /dev/null; then
20
+    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%} 
21
+$(virtualenv_info)$(prompt_char) '
22
+  fi
23
+fi
17 24
 
18 25
 
19 26
 ZSH_THEME_GIT_PROMPT_PREFIX=" on %{$fg[magenta]%}"
... ...
@@ -2,4 +2,4 @@ ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}["
2 2
 ZSH_THEME_GIT_PROMPT_SUFFIX="]%{$reset_color%} "
3 3
 ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg_bold[red]%} x%{$fg_bold[blue]%}"
4 4
 
5
-PROMPT='%{$(git_prompt_info)%}%{$fg_bold[green]%}{%{$(rvm current)%}}%{$reset_color%} %{$fg[cyan]%}%c%{$reset_color%} '
5
+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%} '
... ...
@@ -1,5 +1,13 @@
1 1
 PROMPT='%{$fg_bold[green]%}%p %{$fg[cyan]%}%c%{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}'
2
-RPROMPT='%{$reset_color%} %{$fg[red]%}$(~/.rvm/bin/rvm-prompt i v g) %{$reset_color%}'
2
+
3
+if which rvm-prompt &> /dev/null; then
4
+  RPROMPT='%{$reset_color%} %{$fg[red]%}$(~/.rvm/bin/rvm-prompt i v g) %{$reset_color%}'
5
+else
6
+  if which rbenv &> /dev/null; then
7
+    RPROMPT='%{$reset_color%} %{$fg[red]%}$(rbenv version | sed -e "s/ (set.*$//") %{$reset_color%}'
8
+  fi
9
+fi
10
+
3 11
 
4 12
 ZSH_THEME_GIT_PROMPT_PREFIX=" (%{$fg[red]%}"
5 13
 ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"