dotfiles

<-- duh.
Log | Files | Refs | LICENSE

commit d82be8ca1297e2bcd1d2c96dd4df7ead035f490a
parent 58e895065f94742bc8b6a898f50a8a38721f0ed8
Author: hhvn <dev@hhvn.uk>
Date:   Sun,  2 Jan 2022 16:23:50 +0000

.rcrc: handle $status list for pipelines

Diffstat:
M.rcrc | 38+++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)

diff --git a/.rcrc b/.rcrc @@ -2,16 +2,44 @@ if (grep --version >[2=1] | grep GNU >/dev/null) __prompt_gnu_binary = 'a' +fn __prompt_exit_colour { + if (~ $1 0) { + tput setaf 15 + } else if (~ $1 sig*) { + tput setaf 8 + } else { + tput setaf 10 + } +} + # Backend prompt function fn __prompt { - __prompt_exitcode = $status + __prompt_exitcodes = $status __prompt_gitoutput = 0 - if (~ $__prompt_exitcode 0) { - tput setaf 15 + + # exit codes + # rc produces a list if there is a pipeline + if (~ $__prompt_exitcodes(2) ()) { + # only one + __prompt_exit_colour $__prompt_exitcodes(1) + printf '%s ' $__prompt_exitcodes(1) } else { - tput setaf 10 + tput setaf 3 + printf '[' + __prompt_print_bar = 0 + for (__prompt_exitcode in $__prompt_exitcodes) { + if (~ $__prompt_print_bar 1) { + tput setaf 3 + printf '|' + } else { + __prompt_print_bar = 1 + } + __prompt_exit_colour $__prompt_exitcode + printf '%s' $__prompt_exitcode + } + tput setaf 3 + printf '] ' } - printf '%s ' $__prompt_exitcode # username tput setaf 5