#!/bin/bash width=$((`tput cols` - 29)) width2=$(($width - 2)) if tty -s <&1; then PRETTY='--pretty=format:%Cred%h %Creset %s%x00%Cgreen%cd%x00%C(bold black)%an%Creset%C(yellow)%d' else PRETTY='--pretty=format:%h %s%x00%cd%x00%an%d' fi exec git log --abbrev-commit --date=relative --graph "$PRETTY" "$@" \ |gawk --re-interval -F '\\0' \ '{ printf "%-'$width's%18s %s\n", gensub(/^(.{'$width2'}).{2,}$/, "\\1… ", 1, $1), $2, $3 }' \ |less -R