How to change the color of first word in Windows PowerShell

Posted by Bruce Liu on February 28, 2020

🏷️ Tags: PowerShell , cmder

See the output first.


How to make it?

As shown in the above picture, type the command in your terminal directly. While it is one-time effective.

Set-PSReadlineOption -TokenKind Command -ForegroundColor Black

Place it in your profile and it will run when you launch PowerShell.

  • If it is the first time you set your $profile, you have to enable running unsigned scripts.

    set-executionpolicy remotesigned
    

    Then, add this script.

    'Set-PSReadlineOption -TokenKind Command -ForegroundColor Black' `
    |Add-Content $Profile
    
  • Alternatively, you can add the followings to Microsoft.PowerShell_profile.ps1 located in C:\Users\<username>\Documents\WindowsPowerShell by yourself.

Set-PSReadlineOption -TokenKind Command -ForegroundColor Black
  • If you use some 3rd party terminal, such as ConEmu. You have to change the corresponding profile.ps1.


Reference:


Share on:

« PREVIOUS: A simple way to map landuse
NEXT: Access files using github api »