PowerShellEditorServices: We need a way to customize output color for error/warning, etc

Specifically, in PowerShell.exe we have the ability to change the color used for errors, warnings, etc.:

C:\PS> $Host.PrivateData                                                    
                                      
ErrorForegroundColor    : DarkRed     
ErrorBackgroundColor    : Black       
WarningForegroundColor  : Yellow      
WarningBackgroundColor  : Black       
DebugForegroundColor    : Green       
DebugBackgroundColor    : Black       
VerboseForegroundColor  : Cyan        
VerboseBackgroundColor  : Black       
ProgressForegroundColor : DarkMagenta 
ProgressBackgroundColor : Gray        

In VSCode I can change the colors of the 16 ANSI colors, but I can’t find a way to change which of them you are using to write errors out.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 23 (22 by maintainers)

Commits related to this issue

Most upvoted comments

If anyone is interested in picking this up the general idea is to

  1. Port ConsoleColorProxy and the PrivateData member from ConsoleHost in pwsh to EditorServicesPSHost.PrivateData

  2. Change the Write* methods in EditorServicesPSHostUserInterface to use the new colors

@tylerl0706 Well I changed it in EditorServicesPSHostInterface

public ConsoleColor ErrorForegroundColor { get; set; } = ConsoleColor.DarkCyan;

But it doesn’t change in my pwsh

Here’s my WriteOutput

public override void WriteErrorLine(string value)
        {
            this.WriteOutput(
                value,
                true,
                OutputType.Error,
                foregroundColor: this.ErrorForegroundColor,
                backgroundColor: this.ErrorBackgroundColor);
        }

I did my Invoke-Build Build and there’s no error

Edit

It’s really strange, I change my WriteOutput

public override void WriteErrorLine(string value)
        {
            this.WriteOutput(
                value,
                true,
                OutputType.Error,
                foregroundColor: ConsoleColor.DarkCyan,
                backgroundColor: this.ErrorBackgroundColor);
        }

But my error foreground color is still red !

Edit 2

Nevermind !! It works that was just a little problem from my installation 😃

I will do the Pull Request !

You can always ask questions too!

Let me know if you have any 👍

@tylerl0706 Thank you 😃

I’m not used to stuff like that, so if I have any questions I’ll ask you !