Skip to content

Commit

Permalink
Merge branch 'master' into staging_065
Browse files Browse the repository at this point in the history
Conflicts were:
- README.md: Two commits targeted the brightness table. Powerlevel9k#781 from
14. April 2018 on master and Powerlevel9k#684 from 05. December 2017 on next.
- powerlevel9k.zsh-theme: Two commits targeted the rbenv segment. Both
achieve the same thing: To show the Ruby version number always. Powerlevel9k#795 on
next from 14. April 2018 and Powerlevel9k#610 on master from 28. September 2017. I
went with Powerlevel9k#795 here as this - although being newer - is the one on
master, and that should be more stable.
  • Loading branch information
dritter committed Jun 6, 2018
2 parents 7234d52 + 13b0e38 commit 55473c4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 16 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ The segments that are currently available are:
* [`chruby`](#chruby) - Ruby environment information using `chruby` (if one is active).
* [`rbenv`](#rbenv) - Ruby environment information using `rbenv` (if one is active).
* [`rspec_stats`](#rspec_stats) - Show a ratio of test classes vs code classes for RSpec.
* `rvm` - Ruby environment information using `$GEM_HOME` and `$MY_RUBY_HOME` (if one is active).
* **Rust Segments:**
* `rust_version` - Display the current rust version and [logo](https://www.rust-lang.org/logos/rust-logo-blk.svg).
* **Swift Segments:**
Expand Down Expand Up @@ -213,8 +214,10 @@ You can also change the battery icon automatically depending on the battery
level. This will override the default battery icon. In order to do this, you
need to define the `POWERLEVEL9k_BATTERY_STAGES` variable.

| Variable | Default Value | Description |
| `POWERLEVEL9K_BATTERY_STAGES`|Unset|A string or array, which each index indicates a charge level.|

| Variable | Default Value | Description |
|-------------------------------|---------------|---------------------------------------------------------------|
| `POWERLEVEL9K_BATTERY_STAGES` | Unset | A string or array, which each index indicates a charge level. |

Powerlevel9k will use each index of the string or array as a stage to indicate battery
charge level, progressing from left to right. You can provide any number of
Expand Down Expand Up @@ -254,10 +257,12 @@ As with the battery stages, you can use any number of colors and Powerlevel9k
will automatically use all of them appropriately.

Some example settings:
|Brightness|Possible Array|
|Bright Colors|(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1)|
|Normal Colors|(red3 darkorange3 darkgoldenrod gold3 yellow3 chartreuse2 mediumspringgreen green3 green3 green4 darkgreen)|
|Subdued Colors|(darkred orange4 yellow4 yellow4 chartreuse3 green3 green4 darkgreen)|

| Brightness | Possible Array |
|----------------|---------------------------------------------------------------------------------------------------------------|
| Bright Colors | `(red1 orangered1 darkorange orange1 gold1 yellow1 yellow2 greenyellow chartreuse1 chartreuse2 green1)` |
| Normal Colors | `(red3 darkorange3 darkgoldenrod gold3 yellow3 chartreuse2 mediumspringgreen green3 green3 green4 darkgreen)` |
| Subdued Colors | `(darkred orange4 yellow4 yellow4 chartreuse3 green3 green4 darkgreen)` |

##### command_execution_time

Expand Down Expand Up @@ -538,6 +543,10 @@ Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_RBENV_ALWAYS`|'false'|Always show the `rbenv` segment, even if the local version matches the global.|

| Variable | Default Value | Description |
|----------|---------------|-------------|
|`POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW`|`false`|Set to true if you wish to show the rbenv segment even if the current Ruby version is the same as the global Ruby version|

##### rspec_stats

See [Unit Test Ratios](#unit-test-ratios), below.
Expand Down
28 changes: 18 additions & 10 deletions powerlevel9k.zsh-theme
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,9 @@ prompt_dir() {
fi
;;
*)
current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")"
if [[ $current_path != "~" ]]; then
current_path="$(print -P "%$((POWERLEVEL9K_SHORTEN_DIR_LENGTH+1))(c:$POWERLEVEL9K_SHORTEN_DELIMITER/:)%${POWERLEVEL9K_SHORTEN_DIR_LENGTH}c")"
fi
;;
esac
fi
Expand Down Expand Up @@ -1229,18 +1231,19 @@ prompt_ram() {
"$1_prompt_segment" "$0" "$2" "yellow" "$DEFAULT_COLOR" "$(printSizeHumanReadable "$ramfree" $base)" 'RAM_ICON'
}

################################################################
# Segment to display rbenv information
set_default POWERLEVEL9K_RBENV_ALWAYS false

set_default POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW false
# rbenv information
prompt_rbenv() {
if which rbenv 2>/dev/null >&2; then
if command 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
# unless `POWERLEVEL9K_RBENV_ALWAYS` is set.
if [[ $POWERLEVEL9K_RBENV_ALWAYS == true || $rbenv_version_name != $rbenv_global ]];then
"$1_prompt_segment" "$0" "$2" "red" "$DEFAULT_COLOR" "$rbenv_version_name" 'RUBY_ICON'
# unless `POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW` is set.
if [[ $rbenv_version_name == $rbenv_global && "$POWERLEVEL9K_RBENV_PROMPT_ALWAYS_SHOW" = false ]]; then
return
fi
fi
}
Expand Down Expand Up @@ -1337,8 +1340,13 @@ prompt_status() {
local ec

if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then
ec_text=$(exit_code_or_status "${RETVALS[1]}")
ec_sum=${RETVALS[1]}
if (( $#RETVALS > 1 )); then
ec_text=$(exit_code_or_status "${RETVALS[1]}")
ec_sum=${RETVALS[1]}
else
ec_text=$(exit_code_or_status "${RETVAL}")
ec_sum=${RETVAL}
fi

for ec in "${(@)RETVALS[2,-1]}"; do
ec_text="${ec_text}|$(exit_code_or_status "$ec")"
Expand Down
21 changes: 21 additions & 0 deletions test/segments/dir.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ function testTruncateFoldersWorks() {
unset POWERLEVEL9K_SHORTEN_STRATEGY
}

function testTruncateFolderWithHomeDirWorks() {
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1
CURRENT_DIR=$(pwd)

cd ~
FOLDER="powerlevel9k-test-${RANDOM}"
mkdir -p $FOLDER
cd $FOLDER
# Switch back to home folder as this causes the problem.
cd ..

assertEquals "%K{blue} %F{black}~ %k%F{blue}%f " "$(build_left_prompt)"

rmdir $FOLDER
cd ${CURRENT_DIR}

unset CURRENT_DIR
unset FOLDER
unset POWERLEVEL9K_SHORTEN_DIR_LENGTH
}

function testTruncateMiddleWorks() {
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
POWERLEVEL9K_SHORTEN_STRATEGY='truncate_middle'
Expand Down

0 comments on commit 55473c4

Please sign in to comment.