dotfiles/bin/git-st

37 lines
779 B
Text
Raw Normal View History

2023-12-27 00:43:23 +01:00
#!/usr/bin/env bash
2023-12-28 11:27:46 +01:00
if git branchless query HEAD >/dev/null 2>&1; then
printf '\n ● \e[1m'
git branchless query HEAD
printf '\e[2;38;5;242m%*s\e[0m\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' '-'
fi
2023-12-27 00:43:23 +01:00
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];
}
}
' \
2023-12-28 11:27:46 +01:00
<(git diff --color --stat=$(($(tput cols) - 3)) HEAD | sed '$d; s/^ //') \
<(git -c color.status=always status -sb)
printf '\n'