tpope / vim-fugitive

fugitive.vim: A Git wrapper so awesome, it should be illegal
https://www.vim.org/scripts/script.php?script_id=2975
19.82k stars 1k forks source link

Git log doesn't apply set colors #2304

Closed CRTejaswi closed 3 months ago

CRTejaswi commented 4 months ago

I'm trying to git log using a custom format with colors:

:Git log --pretty=format:"%C(#ff0000)[%aN %as]: %C(#00ff00)%s"

While I get the colors when I issue the command with git at the terminal, I don't get any color when I run it using fugitive in Vim.

How may I fix this?

tpope commented 3 months ago

Fugitive loads the output into a Vim buffer, and Vim buffers don't support terminal escape sequences. The closest thing to what you are looking for is to use a terminal instead, which you can force by using a custom pager:

:Git -c pager.log=less log --pretty=format:"%C(#ff0000)[%aN %as]: %C(#00ff00)%s"

A lot of Fugitive functionality (e.g., jumping to a commit) only works in Vim buffers, so I don't recommend this.

Alternatively, you could customize the syntax highlighting in after/syntax/fugitive.vim. Your choice of punctuation should be very easy to match, in this particular case.