2019-02-28 14:19:09 +08:00
|
|
|
function __fish_print_pipestatus --description "Print pipestatus for prompt"
|
2020-02-03 15:53:41 +08:00
|
|
|
set -l last_status
|
2020-09-05 15:16:49 +08:00
|
|
|
if set -q __fish_last_status
|
|
|
|
set last_status $__fish_last_status
|
2020-02-03 15:53:41 +08:00
|
|
|
else
|
|
|
|
set last_status $argv[-1] # default to $pipestatus[-1]
|
|
|
|
end
|
2019-03-06 02:19:57 +08:00
|
|
|
set -l left_brace $argv[1]
|
|
|
|
set -l right_brace $argv[2]
|
|
|
|
set -l separator $argv[3]
|
2020-09-25 02:08:16 +08:00
|
|
|
|
|
|
|
# Colors default to normal
|
|
|
|
set -q argv[4]
|
|
|
|
and set -l brace_sep_color $argv[4]
|
|
|
|
or set -l brace_sep_color normal
|
|
|
|
set -q argv[5]
|
|
|
|
and set -l status_color $argv[5]
|
|
|
|
or set -l status_color normal
|
|
|
|
|
2019-02-28 14:19:09 +08:00
|
|
|
set -e argv[1 2 3 4 5]
|
|
|
|
|
2020-02-03 15:53:41 +08:00
|
|
|
# Only print status codes if the job failed.
|
2020-03-07 21:13:58 +08:00
|
|
|
# SIGPIPE (141 = 128 + 13) is usually not a failure, see #6375.
|
2020-09-25 02:08:16 +08:00
|
|
|
if not contains $last_status 0 141
|
|
|
|
set -l sep $brace_sep_color$separator$status_color
|
2020-09-25 02:14:10 +08:00
|
|
|
set -l last_pipestatus_string (__fish_status_to_signal $argv | string join "$sep")
|
2020-02-03 15:53:41 +08:00
|
|
|
set -l last_status_string ""
|
|
|
|
if test $last_status -ne $argv[-1]
|
|
|
|
set last_status_string " "$status_color$last_status
|
|
|
|
end
|
2020-09-25 02:08:16 +08:00
|
|
|
printf "%s" $brace_sep_color $left_brace \
|
2020-11-22 21:39:48 +08:00
|
|
|
$status_color $last_pipestatus_string \
|
2020-02-03 15:53:41 +08:00
|
|
|
$brace_sep_color $right_brace $last_status_string (set_color normal)
|
2019-02-28 14:19:09 +08:00
|
|
|
end
|
|
|
|
end
|