summaryrefslogtreecommitdiff
path: root/fish/functions/fish_jj_prompt.fish
blob: b2fb5bab6d8c34514fad41aa89930f899688c75c (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
function fish_jj_prompt --description 'Write out the jj prompt'
    if not command -sq jj
        return 1
    end

    if not jj root --quiet &>/dev/null
        return 1
    end

    set parent_bmarks (jj log --no-graph -r 'bookmarks() & parents(@)' -T 'bookmarks.join(", ")')

    set template "
        surround(
            ' (',
            ')',
            separate(
                ' ',
                if(empty, '∅', '● ' ++ self.diff().files().len()),
                coalesce(
                    surround(
                        '\"',
                        '\"',
                        truncate_end(12, description.first_line(), '…')
                    ),
                    label('description placeholder', '?')
                ),
                change_id.shortest() ++ surround(
                    '<', '>',
                    bookmarks.join(', ')
                ),
                surround('~<', '>', \"$parent_bmarks\"),
                if(conflict, 'X'),
                if(divergent, '☇'),
                if(hidden, '⬚'),
            )
        )"
    jj log --no-graph --color always -r @ -T $template
end