-
Notifications
You must be signed in to change notification settings - Fork 1
/
git-brv
executable file
·45 lines (37 loc) · 915 Bytes
/
git-brv
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
#!/bin/bash
while read -r b1 b2; do
n1=${#b1} n2=${#b2}
len1=$(( n1 > len1 ? n1 : len1))
len2=$(( n2 > len2 ? n2 : len2))
done < <(git branch --format='%(refname:short) %(upstream:short)')
branch="
%(if:equals=*) %(HEAD) %(then)
*%20%(color:green)
%(else)
%(if) %(worktreepath) %(then)
+%20%(color:cyan)
%(else)
%20%20
%(end)
%(end)
%(align:$len1)
%(refname:short)
%(end)
%(color:reset)
"
upstream="
%(if:equals=[gone]) %(upstream:track) %(then)
XX
%(else)
%(upstream:trackshort)
%(end)
"
columns=(
"%(creatordate:format:%Y-%m-%d)"
"${branch//[[:space:]]/}"
"%(color:bold blue)%(align:2)${upstream//[[:space:]]/}%(end)%(color:reset)"
"%(color:red)%(align:$len2)%(upstream:short)%(end)%(color:reset)"
"%(color:yellow)%(objectname:short=10)%(color:reset)"
"%(subject)"
)
git branch --sort='-creatordate' --format="${columns[*]}"