Reply to comment

roger's picture

Resetting PowerShell console colour after running badly-behaved programs

Some programs write their output in different colours. If they're badly-behaved and don't reset the colours when they've finished, your PowerShell console might be left with the wrong background or foreground colours.

This is particularly problematic, because you can't use $HOST.UI.RawUI.BackgroundColor with anything other than the built-in PowerShell colours (which don't match the background used by the default PowerShell shortcut).

The solution is to put [Console]::ResetColor() at the top of your custom prompt function. You do have one of these in your $PROFILE, right?

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <b> <blockquote> <br> <code> <dd> <dl> <dt> <hr> <h1> <h2> <h3> <i> <img> <li> <ol> <p> <pre> <table> <td> <th> <tr> <tt> <u> <ul>
  • Images can be added to this post.

More information about formatting options