Merge pull request #61 from gregf/cmd

Use command -v instead of which
This commit is contained in:
Caio Gondim
2015-09-22 14:16:15 +02:00
2 changed files with 5 additions and 4 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 using Rbenv; version and gemset when on RVM - Current Ruby version using Rbenv or chruby; version and gemset when on RVM
- Current Node.js version, through NVM - Current Node.js version, through NVM
- Git status - Git status
- Timestamp - Timestamp

View File

@@ -337,19 +337,20 @@ prompt_dir() {
# RUBY # RUBY
# RVM: only shows RUBY info if on a gemset that is not the default one # RVM: only shows RUBY info if on a gemset that is not the default one
# RBENV: shows current ruby version active in the shell # RBENV: shows current ruby version active in the shell
# CHRUBY: shows current ruby version active in the shell
prompt_ruby() { prompt_ruby() {
if [[ $BULLETTRAIN_RUBY_SHOW == false ]]; then if [[ $BULLETTRAIN_RUBY_SHOW == false ]]; then
return return
fi fi
if which rvm-prompt &> /dev/null; then if command -v rvm-prompt > /dev/null 2>&1; then
if [[ ! -n $(rvm gemset list | grep "=> (default)") ]] if [[ ! -n $(rvm gemset list | grep "=> (default)") ]]
then then
prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_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 chruby &> /dev/null; then elif command -v chruby > /dev/null 2>&1; then
prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(chruby | sed -e 's/ \* //')" prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(chruby | sed -e 's/ \* //')"
elif which rbenv &> /dev/null; then elif command -v rbenv > /dev/null 2>&1; then
prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(rbenv version | sed -e 's/ (set.*$//')" prompt_segment $BULLETTRAIN_RUBY_BG $BULLETTRAIN_RUBY_FG $BULLETTRAIN_RUBY_PREFIX" $(rbenv version | sed -e 's/ (set.*$//')"
fi fi
} }