I have a git log alias that prints each commit as a single line. Since some people write far too long one-liners in the commit log, many commits wrap to a new line. How can
I put this into ~/bin/git-mylog:
#!/bin/bash
COLS=$(tput cols)
git log --format="tformat:%>|(15)%C(auto)%h %Cgreen %<(20,trunc)%cn %C(auto) %<(15,trunc)%ar %<($((COLS-55)),trunc)%s" --graph
There's a bit going on here, but the guts of it is to use tput cols to get the terminal width and then do some arithmetic to truncate the comment width to the actual space available rather than a fixed width.