fork/fish-shell

git clone https://git.julia.blue/fork/fish-shell

Nahorcolor: prefer `set_color --reset` over `set_color normal`867946468

master
1.4 KiB38 linesraw
1# localization: skip(private)
2function __fish_print_pipestatus --description "Print pipestatus for prompt"
3    set -l last_status
4    if set -q __fish_last_status
5        set last_status $__fish_last_status
6    else
7        set last_status $argv[-1] # default to $pipestatus[-1]
8    end
9    set -l left_brace $argv[1]
10    set -l right_brace $argv[2]
11    set -l separator $argv[3]
12    set -l brace_sep_color $argv[4]
13    set -l status_color $argv[5]
14
15    set -e argv[1 2 3 4 5]
16
17    if not set -q argv[1]
18        echo error: missing argument >&2
19        status print-stack-trace >&2
20        return 1
21    end
22
23    # Only print status codes if the job failed.
24    # SIGPIPE (141 = 128 + 13) is usually not a failure, see #6375.
25    if not contains $last_status 0 141
26        set -l sep $brace_sep_color$separator$status_color
27        set -l last_pipestatus_string (fish_status_to_signal $argv | string join "$sep")
28        set -l last_status_string ""
29        if test "$last_status" -ne "$argv[-1]"
30            set last_status_string " "$status_color$last_status
31        end
32        set -l normal (set_color --reset)
33        # The "normal"s are to reset modifiers like bold - see #7771.
34        printf "%s" $normal $brace_sep_color $left_brace \
35            $status_color $last_pipestatus_string \
36            $normal $brace_sep_color $right_brace $normal $last_status_string $normal
37    end
38end