summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md17
-rwxr-xr-xpowerlevel9k.zsh-theme13
-rwxr-xr-xtest/segments/dir.spec21
3 files changed, 42 insertions, 9 deletions
diff --git a/README.md b/README.md
index a04b4eea..47a62c95 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,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:**
@@ -209,8 +210,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
@@ -250,10 +253,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|(196 202 208 214 220 226 190 154 118 82 46)|
-|Normal Colors|(124 130 136 142 148 112 76 40 34 28 22)|
-|Subdued Colors|( 88 94 100 106 70 34 28 22)|
+
+| Brightness | Possible Array |
+|----------------|-------------------------------------------------|
+| Bright Colors | `(196 202 208 214 220 226 190 154 118 82 46)` |
+| Normal Colors | `(124 130 136 142 148 112 76 40 34 28 22)` |
+| Subdued Colors | `( 88 94 100 106 70 34 28 22)` |
##### command_execution_time
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index 07902ba6..0e09ef03 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -809,7 +809,9 @@ prompt_dir() {
current_path="${cur_short_path: : -1}"
;;
*)
- 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
@@ -1164,8 +1166,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")"
diff --git a/test/segments/dir.spec b/test/segments/dir.spec
index ef27e160..97bc857c 100755
--- a/test/segments/dir.spec
+++ b/test/segments/dir.spec
@@ -36,6 +36,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'