Anto
Anto

Reputation: 7202

Apply output format only to specific commands using [format] config section

I modified gitconfig to obtain a colorful and easier to read git log:

[format]
    pretty = %C(yellow)%h %C(green)(%cd) %C(reset)%s%C(bold yellow)%d %C(bold cyan)<%an>%C(reset)

The issue is that this formatting also applies to git show, so I don't have any easy way to read multiple-lines commit messages anymore.

So far, I came up with two annoying solutions:

Is there any shorter or more elegant way to apply this kind of formatting to the log command only ?

Upvotes: 1

Views: 63

Answers (1)

torek
torek

Reputation: 488183

This is distinctly non-pretty and non-elegant, but at least you can tweak the format in one place:

[alias]
    l = !git log "--pretty=format:\"$(git config --get myformats.log)\"" --decorate

(add ll etc., as desired). The quoting above was found by experiment....

[myformats]
    log = %C(yellow)%h %C(green)(%cd) %C(reset)%s%C(bold yellow)%d %C(bold cyan)<%an>%C(reset)

Upvotes: 1

Related Questions