#!/usr/bin/env bash 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 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) printf '\n'