git - Align information in a column next to graph? - Stack Overflow

git log --graph --oneline --allis quite useful. How can I align the formatted logs to start in the same

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!

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!

Share Improve this question edited Nov 15, 2024 at 22:54 j08691 208k32 gold badges269 silver badges280 bronze badges asked Nov 15, 2024 at 22:03 user3310334user3310334
Add a comment  | 

1 Answer 1

Reset to default 3

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745674150a4639582.html

相关推荐

  • git - Align information in a column next to graph? - Stack Overflow

    git log --graph --oneline --allis quite useful. How can I align the formatted logs to start in the same

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信