fork/fish-shell

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

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

master
2.0 KiB52 linesraw
1# name: Acidhub
2# author: Acidhub - https://acidhub.click/
3
4function fish_prompt -d "Write out the prompt"
5    set -l laststatus $status
6
7    set -l git_info
8    if git rev-parse 2>/dev/null
9        set -l git_branch (
10            command git symbolic-ref HEAD 2>/dev/null | string replace 'refs/heads/' ''
11            or command git describe HEAD 2>/dev/null
12            or echo unknown
13        )
14        set git_branch (set_color -o blue)"$git_branch"
15        set -l git_status
16        if git rev-parse --quiet --verify HEAD >/dev/null
17            and not command git diff-index --quiet HEAD --
18
19            for i in (git status --porcelain | string sub -l 2 | sort | uniq)
20                switch $i
21                    case "."
22                        set git_status "$git_status"(set_color green)✚
23                    case " D"
24                        set git_status "$git_status"(set_color red)✖
25                    case "*M*"
26                        set git_status "$git_status"(set_color green)✱
27                    case "*R*"
28                        set git_status "$git_status"(set_color purple)➜
29                    case "*U*"
30                        set git_status "$git_status"(set_color brown)═
31                    case "??"
32                        set git_status "$git_status"(set_color red)≠
33                end
34            end
35        else
36            set git_status (set_color green):
37        end
38        set git_info "(git$git_status$git_branch"(set_color white)")"
39    end
40
41    # Disable PWD shortening by default.
42    set -q fish_prompt_pwd_dir_length
43    or set -lx fish_prompt_pwd_dir_length 0
44
45    set_color -b black
46    printf '%s%s%s%s%s%s%s%s%s%s%s%s%s' (set_color -o white) '❰' (set_color green) $USER (set_color white) '❙' (set_color yellow) (prompt_pwd) (set_color white) $git_info (set_color white) '❱' (set_color white)
47    if test $laststatus -eq 0
48        printf "%s✔%s≻%s " (set_color -o green) (set_color white) (set_color --reset)
49    else
50        printf "%s✘%s≻%s " (set_color -o red) (set_color white) (set_color --reset)
51    end
52end