Vlad Varvashenko
Vlad Varvashenko

Reputation: 67

How to change the completion/prediction hint color in PowerShell core in windows terminal?

I have got the next problem, the color of the 'diff --staged' on the picture is so gray. How to change the color?

My OS: Windows 11 Environment: Powershell Core & Windows Terminal

enter image description here

Upvotes: 2

Views: 521

Answers (1)

mklement0
mklement0

Reputation: 439812

As Mathias notes:

The gray part is a suggested completion of the command you're typing from your command history:

  • To accept the suggestion (also known as an inline prediction), use the right-arrow key; for more information, including how to customize what key to use, see this answer.

  • To change the color in which the suggestion is printed, see the next section.


Use Set-PSReadLineOption as follows, using Cyan in this example:

Set-PSReadLineOption -Colors @{ InlinePrediction = 'Cyan' }

To make this change for all future sessions too, include the above line in your $PROFILE file, which you can also do programmatically, e.g.:

# Make sure the (current-user, current-host) $PROFILE file exists.
if (-not (Test-Path $PROFILE)) { $null = New-Item -Force $PROFILE }

# Append the Set-PSReadLineOption call to it.
@'

Set-PSReadLineOption -Colors @{ InlinePrediction = 'Cyan' }
'@ | Add-Content $PROFILE

Upvotes: 7

Related Questions