aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/tools/web_config/sample_prompts/acidhub.fish
blob: 45a7223e4c152469cd2c239e98d39a98c33d4d04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# name: Acidhub
# author: Acidhub - https://acidhub.click/

function fish_prompt -d "Write out the prompt"
    set laststatus $status
    function _git_branch_name
        echo (git symbolic-ref HEAD ^/dev/null | sed -e 's|^refs/heads/||')
    end
    function _is_git_dirty
        echo (git status -s --ignore-submodules=dirty ^/dev/null)
    end
    if [ (_git_branch_name) ]
        set -l git_branch (set_color -o blue)(_git_branch_name)
        if [ (_is_git_dirty) ]
            for i in (git branch -qv --no-color|grep \*|cut -d' ' -f4-|cut -d] -f1|tr , \n)\
                (git status --porcelain | cut -c 1-2 | uniq)
                switch $i
                    case "*[ahead *"
                        set git_status "$git_status"(set_color red)⬆
                    case "*behind *"
                        set git_status "$git_status"(set_color red)⬇
                    case "."
                        set git_status "$git_status"(set_color green)✚
                    case " D"
                        set git_status "$git_status"(set_color red)✖
                    case "*M*"
                        set git_status "$git_status"(set_color green)✱
                    case "*R*"
                        set git_status "$git_status"(set_color purple)➜
                    case "*U*"
                        set git_status "$git_status"(set_color brown)═
                    case "??"
                        set git_status "$git_status"(set_color red)≠
                end
            end
        else
            set git_status (set_color green):
        end
        set git_info "(git$git_status$git_branch"(set_color white)")"
    end
    set_color -b black
    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)                 \
    (echo $PWD | sed -e "s|^$HOME|~|") \
    (set_color white)                  \
    $git_info                          \
    (set_color white)                  \
    '❱'                                \
    (set_color white)
    if test $laststatus -eq 0
        printf "%s✔%s≻%s "  \
        (set_color -o green)\
        (set_color white)   \
        (set_color normal)
    else
        printf "%s✘%s≻%s "  \
        (set_color -o red)  \
        (set_color white)   \
        (set_color normal)
    end
end