config/git: improve log viewing experience

This commit is contained in:
xeruf 2021-06-10 11:12:47 +02:00
parent 7910821c3f
commit b5aa87edac
3 changed files with 4 additions and 4 deletions

View File

@ -296,7 +296,6 @@ Version 2019-11-04 2021-02-16"
;; Org startup - https://orgmode.org/manual/In_002dbuffer-Settings.html
(setq org-startup-folded 'show2levels
org-startup-with-inline-images t
org-display-remote-inline-images 'cache)
;; Fix xdg-open & pdfs - https://depp.brause.cc/dotemacs/#orgd97f08c

View File

@ -94,6 +94,7 @@
#dir = !git root | sed 's/$/\\/.git/' | grep --color=never "/" # grep ensures a proper exit status on fail
lg = log --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --graph
lgo = lg HEAD @{push}
lo = log --pretty=tformat:'%C(auto)%h%d %s %Cgreen(%cd) %Cblue<%an>%Creset' --date=human --no-merges
lp = log -p --date=local
ln = !git --no-pager lo "-$(a=$(git rev-list --count HEAD...@{push} 2>/dev/null); expr $a + 3 \\& ${a:-0} \\> 4 \\| 7)" --color=always --graph HEAD @{u} 2>/dev/null | head -9 || git --no-pager lo -7

View File

@ -1,12 +1,12 @@
#!/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} "$@")"
loc="$(git lo --color=always "$@")"
upstream="$(git lo --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
done | ${PAGER:-less}