dotfiles/.local/bin/git-lno

13 lines
545 B
Plaintext
Raw Normal View History

#!/bin/zsh
# Log local and upstream commits side by side
# Useful when the history has been manipulated
loc="$(git ln --color=always "$@")"
upstream="$(git ln --color=always @{push} "$@")"
a=$(echo $loc | wc -l)
b=$(echo $upstream | wc -l)
halfcols="$(expr $(tput cols) / 2)"
for i in $(seq 1 $(test $a -le $b && echo "$a" || echo "$b")); do
printf "%-${halfcols}s $(test $halfcols -lt 100 && echo '\\n')%s\n" "$(echo $loc | head -n $i | tail -1)" "$(echo $upstream | head -n $i | tail -1)"
# use columns instead? - need to interleave!
done