From 7233001b1aed9a30e46c8e4162d4a8b8abfc3d9a Mon Sep 17 00:00:00 2001 From: Amand Tihon Date: Tue, 9 Jun 2009 18:09:43 +0200 Subject: [PATCH] Show exit code as signal name, if terminated by a signal. --- S10_zshopts | 2 ++ S22_exitcode | 14 ++++++++++++++ S60_git | 1 - S90_prompt | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 S22_exitcode diff --git a/S10_zshopts b/S10_zshopts index d90bec0..4f3c2f8 100644 --- a/S10_zshopts +++ b/S10_zshopts @@ -11,6 +11,8 @@ setopt nobeep typeset -ga preexec_functions typeset -ga precmd_functions typeset -ga chpwd_functions +psvar=() + [ -w $zsh_cache ] && HISTFILE=$zsh_cache/history diff --git a/S22_exitcode b/S22_exitcode new file mode 100644 index 0000000..9888b34 --- /dev/null +++ b/S22_exitcode @@ -0,0 +1,14 @@ +#! /usr/bin/zsh + + +parse_exitcode() { + EX=`print -P %?` + psvar[1]=$EX + + if [[ $EX -ge 128 ]] + then + psvar[1]="${signals[${EX}-127]}" + fi +} + +precmd_functions+='parse_exitcode' diff --git a/S60_git b/S60_git index 9eb816b..8926a73 100644 --- a/S60_git +++ b/S60_git @@ -8,7 +8,6 @@ export __ZSH_GIT_VARS_INVALID=1 git_parse() { - psvar=() local git_dir ref base_dir sub_dir action branch git_dir=$(git rev-parse --git-dir 2> /dev/null) || return diff --git a/S90_prompt b/S90_prompt index 2fe519a..a9d379a 100644 --- a/S90_prompt +++ b/S90_prompt @@ -23,7 +23,7 @@ _username="${C_BYELLOW}%n${C_NO}" _machine="${C_BRED}%m${C_NO}" _hour="${C_BCYAN}[%D{%H:%M}]${C_NO}" -_exitcode="%(?::${C_BRED}[ %? ]${C_NO} +_exitcode="%(?::${C_BRED}[ %1v ]${C_NO} )$(true)" _action="%(3v,%3v%,)" -- 2.39.2