From 8315d473f4d0a21b4c4cd5575c92141c2a6ebd7f Mon Sep 17 00:00:00 2001 From: Jarin Udom Date: Fri, 9 May 2014 10:18:44 -0700 Subject: [PATCH] Add chruby support to superjarin prompt, making it definitively the best prompt --- themes/superjarin.zsh-theme | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/themes/superjarin.zsh-theme b/themes/superjarin.zsh-theme index 2920d17a2..15d038735 100644 --- a/themes/superjarin.zsh-theme +++ b/themes/superjarin.zsh-theme @@ -1,9 +1,29 @@ -# Grab the current version of ruby in use (via RVM): [ruby-1.8.7] -if [ -e ~/.rvm/bin/rvm-prompt ]; then +# Grab the current version of ruby in use: [ruby-1.8.7] +if [ -s ~/.rvm/scripts/rvm ]; 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%}" + else + # Loosely adapted from the oh-my-zsh chruby plugin + # + # NOTE: If you're using chruby auto-switching, your .zshrc needs to have this: + # + # source /usr/local/opt/chruby/share/chruby/chruby.sh + # source /usr/local/opt/chruby/share/chruby/auto.sh + # precmd_functions+=("chruby_auto") + # + # It's because the auto thingy is evaluated after the prompt thingy. + + if which chruby &> /dev/null; then + if [[ $(chruby |grep -c \*) -eq 1 ]]; then + _ruby="$(chruby |grep \* |tr -d '* ')" + else + _ruby="system" + fi + + JARIN_CURRENT_RUBY_="%{$fg[white]%}[%{$fg[red]%}$_ruby%{$fg[white]%}]%{$reset_color%}" + fi fi fi