all repos

dotfiles @ 83e573d

i use rach linux btw

dotfiles/config/fish/functions/prompt_vcs.fish (view raw)

1
function prompt_vcs
2
  if command -sq jj; and jj root --quiet >/dev/null 2>&1
3
    set -l head (jj log --no-graph -r "@" -T "change_id.shortest()" 2>/dev/null)
4
    printf ' %s(jj: %s%s%s)%s' (set_color normal) (set_color blue) $head (set_color normal) (set_color normal)
5
    return
6
  end
7
8
  if not command -sq git
9
    return
10
  end
11
12
  set -l status_lines (command git status --porcelain=1 -b --ignore-submodules=dirty 2>/dev/null)
13
  if test $status -ne 0; or test (count $status_lines) -eq 0
14
    return
15
  end
16
17
  set -l branch_line $status_lines[1]
18
  if test -z "$branch_line"
19
    return
20
  end
21
22
  set -l branch (string replace -r '^## ' '' -- $branch_line)
23
  set branch (string replace -r '\\.{3}.*$' '' -- $branch)
24
  set branch (string replace -r '^No commits yet on ' '' -- $branch)
25
  if string match -qr '^HEAD' -- $branch
26
    set branch (command git rev-parse --short HEAD 2>/dev/null; or echo "HEAD")
27
  end
28
29
  set -l dirty ""
30
  if test (count $status_lines) -gt 1
31
    set dirty "*"
32
  end
33
34
  printf ' %s(%s%s%s%s%s)%s' (set_color normal) (set_color blue) $branch (set_color yellow) $dirty (set_color normal) (set_color normal)
35
end