How can I reset the powershell colors

后端 未结 10 1292
梦毁少年i
梦毁少年i 2021-01-30 20:08

I changed the colors of the powershell and now I can\'t change the color of the input text, is always yellow.

I changed the color of the background and

相关标签:
10条回答
  • 2021-01-30 20:38

    I realize this is an old question, but I found it in Google and have another solution.

    Set-PSReadlineOption -TokenKind Command -ForegroundColor Black
    

    Source

    This will change the input text to black. The available color choices are as follows:

    • Black
    • DarkBlue
    • DarkGreen
    • DarkCyan
    • DarkRed
    • DarkMagent
    • DarkYellow
    • Gray
    • DarkGray
    • Blue
    • Green
    • Cyan
    • Red
    • Magenta
    • Yellow
    • White

    You can make this persist by adding it to your profile. It's enough to append the command to the end of the file.

    In my case the profile is in: C:\Users\Billy\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

    To get the location of your PS profile type:

    $profile
    

    If this file doesn't exist, you can create it with:

    New-item –type file –force $profile
    

    (source)

    To see the current settings in your profile, use:

    Get-PSReadlineOption
    

    (source)

    0 讨论(0)
  • 2021-01-30 20:42

    I found the MS page linked to in one of the above answers worked for me just now, today, june 2019

    ms fix for powershell

    I simply pasted their first suggestion - this - into powershell and it seems okay now:


    Set-PSReadLineOption -Colors @{
        #Use a ConsoleColor enum
        "Error"   = [ConsoleColor]::DarkRed
    
        #24 bit color escape sequence
        "String"  = "$([char]0x1b)[38;5;100m"
    
        #RGB value
        "Command" = "#8181f7"
    }
    

    though I'm not 100% sure because the white background I set is still there. But the yellow is gone, that's for sure.

    This is a later edit. I've come back and tried to put all that into a code block instead of just the first line but I can't figure out how to do it.

    Point is you must put all the code between the curly braces in and the #tagged lines are comments. Unfortunately the comments and code are all on the same line and I can't fix it. The comment finishes where the " " text begins.

    Would have been simpler if I'd taken the comments out I guess. Anyway.. June 2019, this is the only technique that worked for me.

    p.s. I now find the fix doesn't work after closing down. When I restart I have to do it again.

    0 讨论(0)
  • 2021-01-30 20:45

    The colors you see by right clicking on the title bar and clicking on Properties are actually stored in the shortcut file itself in the ExtraData section. You can just delete shortcut and recreate it, or you can use a hex editor to change the values. Outside of that, there is not "reset" feature. This is also true for the normal command prompt.

    0 讨论(0)
  • 2021-01-30 20:51

    This resets the console colors (e.g., [Console]::BackgroundColor): (Paste in the powershell console)

    [Console]::ResetColor()
    
    0 讨论(0)
  • 2021-01-30 20:52

    I found this worked. It's the answer from user 577111 I think. We need to put all this into PS.

    Set-PSReadLineOption -Colors @{
    ### Use a ConsoleColor enum 
    "Error" = [ConsoleColor]::DarkRed
    ### 24 bit color escape sequence 
    "String" = "$([char]0x1b)[38;5;100m"
    ### RGB value 
    "Command" = "#8181f7" }
    
    0 讨论(0)
  • 2021-01-30 20:54

    Edit: as pointed out by @dhobbs in the comments, this is no longer an option in PowerShell 6: https://docs.microsoft.com/en-us/powershell/module/PSReadline/Set-PSReadlineOption?view=powershell-6.

    Resetting the PowerShell console colors to their defaults can be done with the following command:

    Set-PSReadlineOption -ResetTokenColors 
    

    Documentation here: https://msdn.microsoft.com/en-us/powershell/reference/5.1/psreadline/set-psreadlineoption

    Add the line to your PowerShell profile to make it have the command run each time a PowerShell console is opened. To see the location of your PowerShell profile, from a PowerShell console type:

    $profile
    
    0 讨论(0)
提交回复
热议问题