fish-shell/share/functions/__fish_print_pipestatus.fish
Johannes Altmanninger 6902459566 prompt: don't print status of last process in pipe twice
If a command fails, print the pipestatus in red instead of yellow and
don't print the status of the last process again. See #6375.

Also use $fish_color_status for coloring status consistently.

Also use __fish_pipestatus_with_signal to print SIGPIPE instead
of a numeric code on e.g.: yes | less +q

[ci skip]
2019-12-11 01:19:12 +01:00

18 lines
819 B
Fish

function __fish_print_pipestatus --description "Print pipestatus for prompt"
set -l left_brace $argv[1]
set -l right_brace $argv[2]
set -l separator $argv[3]
set -l brace_sep_color $argv[4]
set -l status_color $argv[5]
set -e argv[1 2 3 4 5]
# only output status codes if some process in the pipe failed
if string match -qvr '^0$' $argv
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 \
(set_color normal) $status_color $last_pipestatus_string (set_color normal) \
$brace_sep_color $right_brace (set_color normal)
end
end