aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Hilburn <bhilburn@gmail.com>2017-07-27 04:17:02 +0300
committerGitHub <noreply@github.com>2017-07-27 04:17:02 +0300
commit0bcef50e29f55c2858457c8a06da3219b1911a85 (patch)
tree175d1e8a68d93a1f7cc7a7a5519b1604b48bc935
parentc7cd2d54cf9a085d3cad947faf4acb1f960cdcdc (diff)
parentfaa5ec96453ccd6b91ab91d56c68dc5a3ddf554a (diff)
Merge pull request #573 from AdrienHorgnies/feature/status-cross-ok-option-set
Update `status` segment to provide additional configuration option, streamline settings flags.
-rw-r--r--README.md4
-rwxr-xr-xpowerlevel9k.zsh-theme10
2 files changed, 9 insertions, 5 deletions
diff --git a/README.md b/README.md
index f885f877..dce219ac 100644
--- a/README.md
+++ b/README.md
@@ -505,8 +505,8 @@ This segment shows the return code of the last command.
| Variable | Default Value | Description |
|----------|---------------|-------------|
-|`POWERLEVEL9K_STATUS_VERBOSE`|`true`|Set to false if you wish to not show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE` to false.|
-|`POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE`|`false`|Set to true if you wish to show this segment when the last command completed successfully in non-verbose mode.|
+|`POWERLEVEL9K_STATUS_CROSS`|`false`|Set to true if you wish not to show the error code when the last command returned an error and optionally hide this segment when the last command completed successfully by setting `POWERLEVEL9K_STATUS_OK` to false.|
+|`POWERLEVEL9K_STATUS_OK`|`true`|Set to true if you wish to show this segment when the last command completed successfully, false to hide it.|
|`POWERLEVEL9K_STATUS_SHOW_PIPESTATUS`|`true`|Set to true if you wish to show the exit status for all piped commands.|
##### ram
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme
index d941e44d..16904af7 100755
--- a/powerlevel9k.zsh-theme
+++ b/powerlevel9k.zsh-theme
@@ -1086,9 +1086,13 @@ prompt_ssh() {
fi
}
-# Status: return code if verbose, otherwise just an icon if an error occurred
+# old options, retro compatibility
set_default POWERLEVEL9K_STATUS_VERBOSE true
set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false
+# Status: When an error occur, return the error code, or a cross icon if option is set
+# Display an ok icon when no error occur, or hide the segment if option is set to false
+set_default POWERLEVEL9K_STATUS_CROSS false
+set_default POWERLEVEL9K_STATUS_OK true
set_default POWERLEVEL9K_STATUS_SHOW_PIPESTATUS true
prompt_status() {
local ec_text
@@ -1111,12 +1115,12 @@ prompt_status() {
fi
if (( ec_sum > 0 )); then
- if [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
+ if [[ "$POWERLEVEL9K_STATUS_CROSS" == false && "$POWERLEVEL9K_STATUS_VERBOSE" == true ]]; then
"$1_prompt_segment" "$0_ERROR" "$2" "red" "226" "$ec_text" 'CARRIAGE_RETURN_ICON'
else
"$1_prompt_segment" "$0_ERROR" "$2" "$DEFAULT_COLOR" "red" "" 'FAIL_ICON'
fi
- elif [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then
+ elif [[ "$POWERLEVEL9K_STATUS_OK" == true ]] && [[ "$POWERLEVEL9K_STATUS_VERBOSE" == true || "$POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE" == true ]]; then
"$1_prompt_segment" "$0_OK" "$2" "$DEFAULT_COLOR" "green" "" 'OK_ICON'
fi
}