aboutsummaryrefslogtreecommitdiff
path: root/powerlevel9k.zsh-theme
diff options
context:
space:
mode:
authorNate McCurdy <nate.mccurdy@puppetlabs.com>2016-02-13 01:09:04 +0300
committerNateMcCurdy <nate.mccurdy@puppetlabs.com>2016-02-20 01:56:09 +0300
commit01bdee42a21b797d2d7e0b0c032d30e23e1499c9 (patch)
tree64621fb23fd236359ec30600c967bc26d816c0db /powerlevel9k.zsh-theme
parent2d196fa12ffcd579ea310ad676aac9af51e360b2 (diff)
Improve the rbenv prompt by using `version-name`
Prior to this, the rbenv prompt only showed something if the $RBENV_VERSION environment variable was set. This was not a complete solution because rbenv can be configured locally, per directory, with dotfiles. When using dotfiles, the $RBENV_VERSION variables is not set. This fixes the issue by taking the output of the `rbenv version-name` command which shows the real rbenv version being used based on any of the 4 ways to change rbenv as shown here: https://github.com/rbenv/rbenv#choosing-the-ruby-version If the current version of Ruby being used is the same as the global Ruby, nothing is shown. This commit also adds documentation to the README that describes the prompt. Fixes issue #215
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-xpowerlevel9k.zsh-theme12
1 files changed, 10 insertions, 2 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 76ff5497..d0ce097c 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -605,8 +605,16 @@ prompt_ram() {
# rbenv information
prompt_rbenv() {
- if [[ -n "$RBENV_VERSION" ]]; then
- "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$RBENV_VERSION" 'RUBY_ICON'
+ if which rbenv 2>/dev/null >&2; then
+ local rbenv_version_name="$(rbenv version-name)"
+ local rbenv_global="$(rbenv global)"
+
+ # Don't show anything if the current Ruby is the same as the global Ruby.
+ if [[ $rbenv_version_name == $rbenv_global ]]; then
+ return
+ fi
+
+ "$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
fi
}