aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2016-02-21 02:28:44 +0300
committerBen Hilburn <bhilburn@gmail.com>2016-02-21 02:28:44 +0300
commite93d053035e54a50f85ac78377e98dbf0d15e75e (patch)
tree10dcdc710fda65abc50b60c4437a7f79101d5cf7
parent94c87a4d239f770346e510adf46e5844e9023b99 (diff)
parent01bdee42a21b797d2d7e0b0c032d30e23e1499c9 (diff)
Merge pull request #216 from natemccurdy/issues/215
Improve the rbenv prompt by using `version-name`
-rw-r--r--README.md9
-rwxr-xr-xpowerlevel9k.zsh-theme12
2 files changed, 19 insertions, 2 deletions
diff --git a/README.md b/README.md
index bddb6be2..59e45409 100644
--- a/README.md
+++ b/README.md
@@ -246,6 +246,15 @@ specify the correct network interface by setting:
|----------|---------------|-------------|
|`POWERLEVEL9K_IP_INTERFACE`|None|The NIC for which you wish to display the IP address. Example: `eth0`.|
+##### rbenv
+
+This segment shows the version of Ruby being used when using `rbenv` to change your current Ruby stack.
+
+It figures out the version being used by taking the output of the `rbenv version-name` command.
+
+* If `rbenv` is not in $PATH, nothing will be shown.
+* If the current Ruby version is the same as the global Ruby version, nothing will be shown.
+
##### rspec_stats
See [Unit Test Ratios](#unit-test-ratios), below.
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 59733acd..590dc300 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
}