Skip to content

Instantly share code, notes, and snippets.

@orzklv
Created February 21, 2024 17:22
Show Gist options
  • Save orzklv/8dd411fe3b64345852fd9ef2e339201a to your computer and use it in GitHub Desktop.
Save orzklv/8dd411fe3b64345852fd9ef2e339201a to your computer and use it in GitHub Desktop.
Prettier way of showing git log
glog() {
setterm -linewrap off 2> /dev/null
git --no-pager log --all --color=always --graph --abbrev-commit --decorate --date-order \
--format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' "$@" \
| sed -E \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+ /├\1─╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m /\1├─╯\x1b\[m/' \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+/├\1╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m/\1├╯\x1b\[m/' \
-e 's/╮(\x1b\[[0-9;]*m)+\\/╮\1╰╮/' \
-e 's/╯(\x1b\[[0-9;]*m)+\//╯\1╭╯/' \
-e 's/(\||\\)\x1b\[m (\x1b\[[0-9;]*m)/╰╮\2/' \
-e 's/(\x1b\[[0-9;]*m)\\/\1╮/g' \
-e 's/(\x1b\[[0-9;]*m)\//\1╯/g' \
-e 's/^\*|(\x1b\[m )\*/\1⎬/g' \
-e 's/(\x1b\[[0-9;]*m)\|/\1│/g' \
| command less -r $([ $# -eq 0 ] && echo "+/[^/]HEAD")
setterm -linewrap on 2> /dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment