mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 06:20:23 +08:00
prompt: don't print pipestatus if only the last process failed
Example: ps | grep something [ci skip]
This commit is contained in:
parent
6da4b682db
commit
6b2addd9f3
@ -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 \
|
||||
|
Loading…
x
Reference in New Issue
Block a user