From: aram price Date: Mon, 4 Nov 2013 01:58:09 +0000 (-0800) Subject: Add chruby and chruby-auto plugins X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=b48a0f2f65c2fa9cf12e8786aa19308a9109dc8e;p=common%2Fbash_it.git Add chruby and chruby-auto plugins * chruby.bash loads chruby * chruby-auto.bash loads chruby and enables auto-switching * add chruby_version_prompt() function for displaying ruby version * inspired by https://gist.github.com/rssvihla/6153455 --- diff --git a/plugins/available/chruby-auto.bash b/plugins/available/chruby-auto.bash new file mode 100644 index 0000000..49efc50 --- /dev/null +++ b/plugins/available/chruby-auto.bash @@ -0,0 +1,5 @@ +cite about-plugin +about-plugin 'load chruby + auto-switching (from /usr/local/share/chruby)' + +source /usr/local/share/chruby/chruby.sh +source /usr/local/share/chruby/auto.sh diff --git a/plugins/available/chruby.bash b/plugins/available/chruby.bash new file mode 100644 index 0000000..c679347 --- /dev/null +++ b/plugins/available/chruby.bash @@ -0,0 +1,4 @@ +cite about-plugin +about-plugin 'load chruby (from /usr/local/share/chruby)' + +source /usr/local/share/chruby/chruby.sh diff --git a/themes/base.theme.bash b/themes/base.theme.bash index 5a5edd3..001ca65 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -132,8 +132,18 @@ function rbfu_version_prompt { fi } +function chruby_version_prompt { + if declare -f -F chruby &> /dev/null; then + if declare -f -F chruby_auto &> /dev/null; then + chruby_auto + fi + chruby=$(ruby --version | awk '{print $1, $2;}') || return + echo -e "$CHRUBY_THEME_PROMPT_PREFIX$chruby$CHRUBY_THEME_PROMPT_SUFFIX" + fi +} + function ruby_version_prompt { - echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)" + echo -e "$(rbfu_version_prompt)$(rbenv_version_prompt)$(rvm_version_prompt)$(chruby_version_prompt)" } function virtualenv_prompt {