dotfiles/bin/git-st

32 lines
633 B
Text
Raw Normal View History

2023-12-27 00:43:23 +01:00
#!/usr/bin/env bash
git branchless smartlog || true
printf '\n'
awk -vOFS='' '
NR==FNR {
all[i++] = $0;
difffiles[$1] = $0;
next;
}
! ($2 in difffiles) {
print; next;
}
{
gsub($2, difffiles[$2]);
print;
}
END {
if (NR != FNR) {
# Had diff output
exit;
}
# Had no diff output, just print lines from git status -sb
for (i in all) {
print all[i];
}
}
' \
<(git diff --color --stat=$(($(tput cols) - 3)) HEAD | sed '$d; s/^ //')\
<(git -c color.status=always status -sb)