Git Console color scheme
We use pre commit hooks to run out test suite when committing changes in git, and the logs for that are printed in the Git Console. However, all text is red making it really hard to find failing tests if any fail, see below
Is it possible to change this color scheme to be more like the normal terminal, where we do have different colors for different states?
Please sign in to leave a comment.
Have you tried adjusting the colors in
Editor → Color Scheme → Console Colors
?No, but that seems to have many colors pre defined, not just red:


So based on above I would expect the output (of passing tests) to be more like this:
Hi,
Please see: https://youtrack.jetbrains.com/issue/IDEA-210301/Support-terminal-colors-in-VCS-console
You can adjust them in git hooks themselves and they will be respected via console.
I don't have ASCII escape characters, so I wouldn't know what to adjust.
My hook just calls a PS1 script:
#!/bin/sh
echo
exec powershell.exe -ExecutionPolicy RemoteSigned -File '.\pre-commit.ps1'
exit
Which executes dotnet test:
#!powershell
# This can be called manually with:
# .\pre-commit -a
Write-Host "Running tests"
dotnet test
Write-Host "Testing complete. Exit code: $LASTEXITCODE"
# Pass the failure code back to the pre-commit hook
exit $LASTEXITCODE
If you are running Powershell 7.2 or greater try setting the
$PSStyle
variable to Ansi.e.g.
$PSStyle.OutputRendering = 'Ansi'
See this MS doc for more detail: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_ansi_terminals?view=powershell-7.4
Also, is the
exec
command really necessary in your hook? Have you tried your hook without it? Or maybe try having the powershell script directly in the hook like this:You might need to use
#!/usr/bin/env powershell
if you are not using Powershell CoreHope this helps!
Apparently the version of powershell git console uses is not configurable? I've set the Terminal to use Powershell 7 (7.4.1) but even after an IDE restart the git console still uses Windows Powershell instead of Powershell 7. So this solution also doesn't work.
And git hooks can't use powershell because powershell 7.2+ requires the .ps1 extension.
I believe Git & Rider will pick the version of Powershell based on the PATH env variable, just make sure the version you want to use it the first one in the PATH. I have
C:\Program Files\PowerShell\7\
in my path, without it thepwsh.exe
command fails both from Rider and from the command line.Also, I did some experimenting and it seems like the results depend upon how the command in question writes it's output.
For example, using the
-ForegroundColor
flag toWrite-Host
doesn't have the desired affect when run through a bash shell such as git bash, or the VCS console in Rider. However, directly setting the ANSI escape sequences via$PSStyle.Background
and$PSStyle.Foreground
does have the desired affect.So it would appear that the dotnet command doesn't write it's output in a way that the VCS console (and probably bash, git bash, etc.) can colorize.
Here is the test hook I used, note I embedded the Powershell commands directly in the shell script, but the results were the same using a separate PS script file.
Actual Output (VCS Console):

Expected Output (from a powershell terminal):

Output from Git Bash terminal:

After some digging I must agree. dotnet console commands, or .Net console applications in general really, don't use ANSI nor do they seem to support it properly currently (not some mode you can just switch on). So sadly, without something like a proxy layer that translates UNICODE to ANSI for colors it does not seems like we can change this behavior unless the VCS console gets native support for Powershell.
- .net - get dotnet to output using ansi escape sequences - Stack Overflow
- Using ANSI colour codes in .NET Core Console applications | Jerrie Pelser's Blog (archive.org)
Hi,
They ide should start in the shell that is default in your system.
Can you run the IDE from the terminal where these hooks have colors (if possible) and test it?