Merge pull request #58 from vadviktor/vadviktor-patch-unified-ruby

Adding Rbenv support for RVM branch
This commit is contained in:
Caio Gondim
2015-09-18 13:20:57 +02:00
2 changed files with 24 additions and 20 deletions

View File

@@ -13,7 +13,7 @@ simplicity, showing information only when it's relevant.
It currently shows: It currently shows:
- Current Python virtualenv - Current Python virtualenv
- Current Ruby version and gemset, through RVM - Current Ruby version using Rbenv; version and gemset when on RVM
- Current Node.js version, through NVM - Current Node.js version, through NVM
- Git status - Git status
- Timestamp - Timestamp
@@ -154,14 +154,14 @@ or don't want to see. All options must be overridden in your **.zshrc** file.
|`BULLETTRAIN_NVM_FG`|`white`|Foreground color |`BULLETTRAIN_NVM_FG`|`white`|Foreground color
|`BULLETTRAIN_NVM_PREFIX`|`"⬡ "`|Prefix of the segment |`BULLETTRAIN_NVM_PREFIX`|`"⬡ "`|Prefix of the segment
### Ruby RVM ### Ruby RVM/Rbenv
|Variable|Default|Meaning |Variable|Default|Meaning
|--------|-------|-------| |--------|-------|-------|
|`BULLETTRAIN_RVM_SHOW`|`true`|Show/hide that segment |`BULLETTRAIN_RUBY_SHOW`|`true`|Show/hide that segment
|`BULLETTRAIN_RVM_BG`|`magenta`|Background color |`BULLETTRAIN_RUBY_BG`|`magenta`|Background color
|`BULLETTRAIN_RVM_FG`|`white`|Foreground color |`BULLETTRAIN_RUBY_FG`|`white`|Foreground color
|`BULLETTRAIN_RVM_PREFIX`|`"♦"`|Prefix of the segment |`BULLETTRAIN_RUBY_PREFIX`|`"♦"`|Prefix of the segment
### Dir ### Dir

View File

@@ -79,18 +79,18 @@ if [ ! -n "${BULLETTRAIN_NVM_PREFIX+1}" ]; then
BULLETTRAIN_NVM_PREFIX="⬡ " BULLETTRAIN_NVM_PREFIX="⬡ "
fi fi
# RMV # RUBY
if [ ! -n "${BULLETTRAIN_RVM_SHOW+1}" ]; then if [ ! -n "${BULLETTRAIN_RUBY_SHOW+1}" ]; then
BULLETTRAIN_RVM_SHOW=true BULLETTRAIN_RUBY_SHOW=true
fi fi
if [ ! -n "${BULLETTRAIN_RVM_BG+1}" ]; then if [ ! -n "${BULLETTRAIN_RUBY_BG+1}" ]; then
BULLETTRAIN_RVM_BG=magenta BULLETTRAIN_RUBY_BG=magenta
fi fi
if [ ! -n "${BULLETTRAIN_RVM_FG+1}" ]; then if [ ! -n "${BULLETTRAIN_RUBY_FG+1}" ]; then
BULLETTRAIN_RVM_FG=white BULLETTRAIN_RUBY_FG=white
fi fi
if [ ! -n "${BULLETTRAIN_RVM_PREFIX+1}" ]; then if [ ! -n "${BULLETTRAIN_RUBY_PREFIX+1}" ]; then
BULLETTRAIN_RVM_PREFIX=♦️ BULLETTRAIN_RUBY_PREFIX=♦️
fi fi
# DIR # DIR
@@ -334,17 +334,21 @@ prompt_dir() {
prompt_segment $BULLETTRAIN_DIR_BG $BULLETTRAIN_DIR_FG $dir prompt_segment $BULLETTRAIN_DIR_BG $BULLETTRAIN_DIR_FG $dir
} }
# RVM: only shows RVM info if on a gemset that is not the default one # RUBY
prompt_rvm() { # RVM: only shows RUBY info if on a gemset that is not the default one
if [[ $BULLETTRAIN_RVM_SHOW == false ]] then # RBENV: shows current ruby version active in the shell
prompt_ruby() {
if [[ $BULLETTRAIN_RUBY_SHOW == false ]] then
return return
fi fi
if which rvm-prompt &> /dev/null; then if which rvm-prompt &> /dev/null; then
if [[ ! -n $(rvm gemset list | grep "=> (default)") ]] if [[ ! -n $(rvm gemset list | grep "=> (default)") ]]
then then
prompt_segment $BULLETTRAIN_RVM_BG $BULLETTRAIN_RVM_FG $BULLETTRAIN_RVM_PREFIX" $(rvm-prompt i v g)" prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(rvm-prompt i v g)"
fi fi
elif which rbenv &> /dev/null; then
prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(rbenv version | sed -e 's/ (set.*$//')"
fi fi
} }
@@ -435,7 +439,7 @@ build_prompt() {
RETVAL=$? RETVAL=$?
prompt_time prompt_time
prompt_status prompt_status
prompt_rvm prompt_ruby
prompt_virtualenv prompt_virtualenv
prompt_nvm prompt_nvm
prompt_context prompt_context