Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Add chruby options #816

Merged
merged 3 commits into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,17 @@ Some example settings:
| Normal Colors | `(124 130 136 142 148 112 76 40 34 28 22)` |
| Subdued Colors | `( 88 94 100 106 70 34 28 22)` |

##### chruby

This segment shows the version of Ruby being used when using `chruby` to change your current Ruby stack.

It uses `$RUBY_ENGINE` and `$RUBY_VERSION` as set by `chruby`.

| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_CHRUBY_SHOW_ENGINE`|true|Show the currently selected Ruby engine (e.g. `ruby`, `jruby`, `rbx`, etc)
|`POWERLEVEL9K_CHRUBY_SHOW_VERSION`|true|Shows the currently selected engine's version (e.g. `2.5.1`)

##### command_execution_time

Display the time the previous command took to execute if the time is above
Expand Down
21 changes: 17 additions & 4 deletions powerlevel9k.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -1086,11 +1086,24 @@ prompt_rbenv() {
# chruby information
# see https://github.com/postmodern/chruby/issues/245 for chruby_auto issue with ZSH
prompt_chruby() {
local chruby_env
chrb_env="$(chruby 2> /dev/null | grep \* | tr -d '* ')"
# Uses $RUBY_VERSION and $RUBY_ENGINE set by chruby
set_default POWERLEVEL9K_CHRUBY_SHOW_VERSION true
set_default POWERLEVEL9K_CHRUBY_SHOW_ENGINE true
local chruby_label=""

if [[ "$POWERLEVEL9K_CHRUBY_SHOW_ENGINE" == true ]]; then
chruby_label+="$RUBY_ENGINE "
fi
if [[ "$POWERLEVEL9K_CHRUBY_SHOW_VERSION" == true ]]; then
chruby_label+="$RUBY_VERSION"
fi

# Truncate trailing spaces
chruby_label="${chruby_label%"${chruby_label##*[![:space:]]}"}"

# Don't show anything if the chruby did not change the default ruby
if [[ "${chrb_env:-system}" != "system" ]]; then
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chrb_env}" 'RUBY_ICON'
if [[ "$RUBY_ENGINE" != "" ]]; then
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "${chruby_label}" 'RUBY_ICON'
fi
}

Expand Down