user3310334
user3310334

Reputation:

Align information in a column next to graph?

git log --graph --oneline --all

is quite useful. How can I align the formatted logs to start in the same column though?

For example

git log --graph --oneline --all --format='%C(auto)%<|(15)%h %d %s'

got me quite close, thanks to

%<|( <M> )
make the next placeholder take at least until Mth display column, padding spaces on the right if necessary.

But a hardcoded %<|(15) will not keep working once the graph itself becomes wider than 15 characters!

Upvotes: -1

Views: 75

Answers (1)

jthill
jthill

Reputation: 60235

You're going to need to postprocess the output, column alignment is a two-pass algorithm, that kind of pretty is outside git log's remit.

First cut at it (for portable scripting put #!/bin/bash up front):

git log --graph --oneline --all --color=always \
| sed 's,.*\x1b\[m ,&\t,' | column -ts$'\t'

which passed my smoketests on a couple histories I've got handy.

Upvotes: 3

Related Questions