tpope/vim-fugitive

Is there a way to "force" color to be enabled for a Git command that just loads a split?

nebbish opened this issue · 2 comments

I have a couple of "log" related aliases for creating "pretty" log output with the graph lines.
When I run them in a command window (or even a VIM terminal window) the lines are colored.

In the screenshot, I opened a Gvim right in the plugin folder (%userprofile%.vim\bundle\vim-fugitive).
Also I stashed something just to "create a graph" for Git to output.
My personal alias, hlag, is: log --graph --pretty=with-16-date --all --date=human --decorate

The screenshot is from:

:0G
:G hlag
:vert term

Then in the term:

git hlag

fugitive-without-color-while-term-has-color

I know that Fugitive works hard behind the scenes to forcibly disable colors -- even for users with color.ui=always in their global config.

My current work involves a repository with many active threads of development, and it is a big repo.
I am very interested in getting the GIT log output, with colorized graph lines into a buffer so I can jump around, mentally following our branching work -- but only with the help of colors.

(as of now... no way am I jumping 3 page-up(s), and trusting 3rd-from-left is still the same thread of commits)

PS: I think it would be just fine if the color codes came into the buffer raw (e.g. ^[[#m). I have my own way to convert them to syntax highlighting (using this plugin).

You can force it on a per-command basis with :Git -c color.diff=always hlag. I'm pushing a change that will let you put the -c color.diff=always inside the alias itself, so that :Git hlag can do what you desire.

I know that Fugitive works hard behind the scenes to forcibly disable colors -- even for users with color.ui=always in their global config.

I think per-alias is probably appropriate for your use case, but I would be open to dialing this back a bit if there was a compelling reason. The reason it was added is because true used to be an alias for always, which meant many users had it enabled without understanding the implications, resulting in a bad out-of-the-box experience for Fugitive.

Oh, I did not think to include the -c option with the fugitive command. That worked great, and is a good solution for me 😄.

I believe in: simple things should be simple, and hard things should be doable.
And this make the hard thing doable 😃.

I use VIM mappings to run my fugitive commands. I will just add that to my own mappings to get the color I am after.
I am not ready to ask that the defaults should change for this.