diff options
author | Ben Hilburn <bhilburn@gmail.com> | 2017-08-03 22:59:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-03 22:59:08 +0300 |
commit | 93a1c4d2e86ea2c031165199d6d4dba1adf46468 (patch) | |
tree | 393548290c03a01299f352a821394e3e6fb24a71 /powerlevel9k.zsh-theme | |
parent | 176559a050e884964122202cc329d0b174366500 (diff) | |
parent | 41b469ed9b803a617b103bd65c842138f359ad82 (diff) |
Merge pull request #581 from docwhat/pr/show-signals
status: show signal name
Diffstat (limited to 'powerlevel9k.zsh-theme')
-rwxr-xr-x | powerlevel9k.zsh-theme | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/powerlevel9k.zsh-theme b/powerlevel9k.zsh-theme index d6ce38f1..c2b53374 100755 --- a/powerlevel9k.zsh-theme +++ b/powerlevel9k.zsh-theme @@ -1083,31 +1083,47 @@ prompt_ssh() { fi } -# 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 +set_default POWERLEVEL9K_STATUS_HIDE_SIGNAME false +# old options, retro compatibility +set_default POWERLEVEL9K_STATUS_VERBOSE true +set_default POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE false + +exit_code_or_status() { + local ec=$1 + if [[ "$POWERLEVEL9K_STATUS_HIDE_SIGNAME" = true ]]; then + echo "$ec" + elif (( ec <= 128 )); then + echo "$ec" + else + local sig=$(( ec - 128 )) + local idx=$(( sig + 1 )) + echo "${signals[$idx]}(-${sig})" + fi +} + prompt_status() { local ec_text local ec_sum local ec if [[ $POWERLEVEL9K_STATUS_SHOW_PIPESTATUS == true ]]; then - ec_text=${RETVALS[1]} + ec_text=$(exit_code_or_status "${RETVALS[1]}") ec_sum=${RETVALS[1]} for ec in "${(@)RETVALS[2,-1]}"; do - ec_text="${ec_text}|${ec}" + ec_text="${ec_text}|$(exit_code_or_status "$ec")" ec_sum=$(( $ec_sum + $ec )) done else # We use RETVAL instead of the right-most RETVALS item because # PIPE_FAIL may be set. - ec_text=${RETVAL} + ec_text=$(exit_code_or_status "${RETVAL}") ec_sum=${RETVAL} fi |