Use BASH instead of grep(1)
Much like my previous commit, grep(1) isn't needed here at all. BASH can handle REGEX as well as glob pattern matching in a very similar way. In this commit, I've made use of a `while read` loop to achieve the same thing as before, but much more efficiently. If it turns out that the `rbenv` command usually returns a crap ton of data (10s of thousands of lines, at _least_), then please ignore this commit.pull/1840/head
parent
4fd66d4751
commit
387425e2b2
|
|
@ -281,7 +281,7 @@ function git_prompt_vars {
|
||||||
SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
SCM_PREFIX=${GIT_THEME_PROMPT_PREFIX:-$SCM_THEME_PROMPT_PREFIX}
|
||||||
SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
SCM_SUFFIX=${GIT_THEME_PROMPT_SUFFIX:-$SCM_THEME_PROMPT_SUFFIX}
|
||||||
|
|
||||||
SCM_CHANGE=$(_git-short-sha 2> /dev/null || echo "")
|
SCM_CHANGE=$(_git-short-sha 2> /dev/null || echo)
|
||||||
}
|
}
|
||||||
|
|
||||||
function p4_prompt_vars {
|
function p4_prompt_vars {
|
||||||
|
|
@ -391,7 +391,17 @@ function rvm_version_prompt {
|
||||||
function rbenv_version_prompt {
|
function rbenv_version_prompt {
|
||||||
if which rbenv &> /dev/null; then
|
if which rbenv &> /dev/null; then
|
||||||
rbenv=$(rbenv version-name) || return
|
rbenv=$(rbenv version-name) || return
|
||||||
rbenv commands | grep -q gemset && gemset=$(rbenv gemset active 2> /dev/null) && rbenv="$rbenv@${gemset%% *}"
|
|
||||||
|
while read; do
|
||||||
|
if [[ $REPLY == *gemset* ]]; then
|
||||||
|
if gemset=$(rbenv gemset active 2> /dev/null); then
|
||||||
|
rbenv="$rbenv@${gemset%% *}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done <<< "$(rbenv commands)"
|
||||||
|
|
||||||
if [ "$rbenv" != "system" ]; then
|
if [ "$rbenv" != "system" ]; then
|
||||||
echo -e "$RBENV_THEME_PROMPT_PREFIX$rbenv$RBENV_THEME_PROMPT_SUFFIX"
|
echo -e "$RBENV_THEME_PROMPT_PREFIX$rbenv$RBENV_THEME_PROMPT_SUFFIX"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue