Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of first input word in PowerShell

Tags:

powershell

I want to change color of first console statement from yellow to some another color because it looks bad on a white background. How can i do this ? enter image description here

enter image description here

like image 912
Vovan Avatar asked Mar 25 '17 10:03

Vovan


People also ask

How do I change text color in PowerShell?

You can specify the color of text by using the ForegroundColor parameter, and you can specify the background color by using the BackgroundColor parameter. The Separator parameter lets you specify a string to use to separate displayed objects.

What is ${} in PowerShell?

The ${} notation actually has two uses; the second one is a hidden gem of PowerShell: That is, you can use this bracket notation to do file I/O operations if you provide a drive-qualified path, as defined in the MSDN page Provider Paths.

How do I change the default color in PowerShell?

As mentioned earlier, Windows PowerShell console displays white on blue by default and red on black for error messages, so to change colors, right-click on the PowerShell Window top-bar, and select 'Properties'.


2 Answers

The syntax highlighting comes from PSReadLine. To set the foreground color for Command tokens (which shows in yellow by default), use Set-PSReadLineOption:

Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkGreen

Place that statement in your $profile to have it run every time you launch PowerShell:

'Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkGreen' |Add-Content $Profile
like image 132
Mathias R. Jessen Avatar answered Sep 27 '22 23:09

Mathias R. Jessen


Update: Use this command instead for newer versions:

Set-PSReadLineOption -Colors @{ Command = 'Red' }

Color list:

  • Black
  • DarkBlue
  • DarkGreen
  • DarkCyan
  • DarkRed
  • DarkMagenta
  • DarkYellow
  • Gray
  • DarkGray
  • Blue
  • Green
  • Cyan
  • Red
  • Magenta
  • Yellow
  • White
like image 45
Hugo B. S. Benedicto Avatar answered Sep 27 '22 22:09

Hugo B. S. Benedicto