prompt: don't print pipestatus if only the last process failed

Example: ps | grep something

[ci skip]
This commit is contained in:
Johannes Altmanninger 2019-12-10 22:32:35 +01:00
parent 6da4b682db
commit 6b2addd9f3

View File

@ -6,8 +6,10 @@ function __fish_print_pipestatus --description "Print pipestatus for prompt"
set -l status_color $argv[5]
set -e argv[1 2 3 4 5]
# only output $pipestatus if there was a pipe and any part of it had non-zero exit status
if set -q argv[2] && string match -qvr '^0$' $argv
# only output $pipestatus if there was a pipe
# and any part of it but the last one had non-zero exit status
# if only the last process failed, prompts already print $status which is $pipestatus[-1]
if set -q argv[2] && string match -qvr '^0$' $argv[1..-2]
set -l sep (set_color normal){$brace_sep_color}{$separator}(set_color normal){$status_color}
set -l last_pipestatus_string (string join "$sep" (__fish_pipestatus_with_signal $argv))
printf "%s%s%s%s%s%s%s%s%s%s" (set_color normal )$brace_sep_color $left_brace \