I want to change the Xterm background color based on what branch I'm currently in. Is there a good way to automate this?
Currently I'm changing the profile by hand. And I find it a bit annoying that google couldn't provide me with an answer. Everyone seems settled by just changing the prompt.
You could start with "fixing the prompt": some of those answers deal with modifying the (bash or zsh) prompts to send escape sequences which change the window title. The background color for xterm would be just another escape sequence, part of the same group of Operating System Commands:
OSC Ps ; Pt BEL
OSC Ps ; Pt ST
Set Text Parameters. For colors and font, if Pt is a "?", the
control sequence elicits a response which consists of the con-
trol sequence which would set the corresponding value. The
dtterm control sequences allow you to determine the icon name
and window title.
...
The 10 colors (below) which may be set or queried using 1 0
through 1 9 are denoted dynamic colors, since the correspond-
ing control sequences were the first means for setting xterm's
colors dynamically, i.e., after it was started. They are not
the same as the ANSI colors. These controls may be disabled
using the allowColorOps resource. At least one parameter is
expected for Pt. Each successive parameter changes the next
color in the list. The value of Ps tells the starting point
in the list. The colors are specified by name or RGB specifi-
cation as per XParseColor.
...
Ps = 1 0 -> Change VT100 text foreground color to Pt.
Ps = 1 1 -> Change VT100 text background color to Pt.
With xterm (not necessarily for "xterm" imitators...),
printf '\033]11;blue\007'
printf '\033]11;white\007'
changes the window background to blue and then white.
Unlike settings for "ANSI colors", the dynamic colors persist, will not be reset by other escape sequences.
Oddly, xterm: how to change the background color? suggests "two" (actually one) different way for setting the background color, but that's not useful for your purpose.
In powershell under W10, when I type cd "xxxx", the "xxxx" are not visible on the screen (the cursor moves but the characters print in the same color as the background). When I type the first double quote then the > at the beginning of the line turns red and when I type final quotes it turns back to white and the rest of the line is visible.
For example if I type:
>cd "Desktop" Hello
I get:
>cd Hello
My powershell used to work well until yesterday... Do you know how to correct this bug?
Edit
I found out why this happens, it has to do with the palette in the Colors tab.
If you edit the values in the palette when choosing your text/background colors (which I did by accident), you can change the color of quoted strings.
The 4th value is the one related to quoted strings:
Hope it helps!
Old solution
The command below suggested by TravisEz13 works.
remove-module psreadline
But it also removes the nice syntax highlight. It's local solution, you'll have to do it every time you open a new PowerShell session.
In my job I have recently begun using Powershell quite frequently. To facilitate using it, I am attempting to customize the command prompt colors to my liking, but I have run into a snag when attempting to customize the color of quoted string values. Given how PS is a text based interface, this statement may not mean that much, so please refer to this
Apparently I can't embed images yet, so you'll have to click the link.
Anyway, this text is extremely difficult for me to read, and I am attempting to switch it over to something with more contrast, but I can't find a setting for it.
I've looked at the following options already:
Setting these colors in the UI (right-click context menu), but that only allows setting default foreground and background
Setting the color utilizing $host.UI.RawUI, but this also only allows setting the default foreground and background
Setting the color using $host.PrivateData, but while this provides more options, it doesn't seem to have options for setting the more context sensitive items like the quoted text or even the variable you can see in the image.
My fallback plan is to use PowerShell ISE if I must (it allows me to customize this), but I would prefer to have a lighter weight command prompt available if possible.
Has anyone figured out how to change this?
I'm using PowerShell v5 on Windows 10.
PowerShell 5.0 ships with PSReadLine, a module that enhances the editing experience in the console by adding syntax highlight coloring among other things.
You can change the color of string tokens with Set-PSReadLineOption, for example:
Set-PSReadlineOption -TokenKind String -ForegroundColor Cyan
For PSReadLine version 2.0 and up, use the -Colors parameter and supply a dictionary of (optional) token color overrides to Set-PSReadLineOption:
Set-PSReadLineOption -Colors #{ String = 'Cyan' }
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 the color of the text
The color of the background changed correctly but in the display text the color still is yellow.
Can I do something to reset the colors?
This resets the console colors (e.g., [Console]::BackgroundColor): (Paste in the powershell console)
[Console]::ResetColor()
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)
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.
Answer
With respect to the original question, the yellow text is intentional. It is syntax coloring from the PSReadLine module. This coloring is the (new) default for Windows PowerShell.
As PetSerAl mentioned, Remove-Module PSReadline will remove the highlighting for that session. If you want to permanently remove PSReadLine then modify your PowerShell profile with these PowerShell commands:
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
Add-Content $PROFILE "`nRemove-Module PSReadline"
If you want to change the syntax coloring, follow the documentation for Set-PSReadLineOption. Specifically, look at parameters with "color" in their name. And make sure to set the version in the documentation to match your PowerShell version. (One exception is Windows 10 version 1809 and later which uses the PowerShell 6.0 syntax.)
Example
For example, if you wanted to change the command text color from yellow to magenta then (using the PowerShell 6 syntax) you could enter the following into a PowerShell:
Set-PSReadLineOption -Colors #{
"Command" = [ConsoleColor]::Magenta
}
Keep in mind this is temporary and would have to be added to your PowerShell profile to become permanent.
Fixing Shortcut Colors
If, on the other hand, you saw the shortcut properties screen capture in the original question and thought, "Hey, I screwed up my shortcut colors," then this answer is for you.
As Drew Chapin points out, an easy solution to fix that issue is to recreate the shortcut. But if you just create a new shortcut and point it to powershell.exe, you'll get a black and white shell.
If you want the nice blue and white shell, you'll have to do something else.
Before you create new shortcuts, it is a good idea to clear out the ones causing the problem. If you have them pinned somewhere and are not sure where the actual shortcut file is located then below are some common locations. Enter these paths into the File Explorer address bar, one at a time, and poke around. In some instances, I give the path to a parent folder and suggest that you use the search function in File Explorer to search for "powershell" in the subfolders:
shell:Common Desktop
shell:Common Start Menu search for "powershell"
shell:Common Startup
shell:Quick Launch
shell:Start Menu search for "powershell"
shell:Startup
shell:User Pinned search for "powershell"
Creating New PowerShell Shortcuts
Coming back to fresh shortcuts, the do-it-yourself solution is to create a new Windows user and to copy the PowerShell shortcuts from their start menu. You can find the shortcuts by opening File Explorer and navigating to:
shell:Start Menu\Programs\Windows PowerShell
If you don't want to go through the trouble of creating a new user or are unable to do so, I created a PowerShell script that will create the shortcuts for you. Change directory to where you want the shortcuts created. Then either paste the following commands in a PowerShell or save and execute them as a .ps1 file. Remember that the shortcuts will be created in the current working directory.
Example
Open PowerShell.
Change directory to the PowerShell folder in the Start Menu.
set-location "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Windows PowerShell"
Remove the existing shortcuts (if they're giving you problems).
remove-item .\*.lnk -whatif
Run the script below.
# Base64-encoded PowerShell .lnk files from a new Windows user profile.
# Windows 10.0.17763.615 en-US
$windowsPowerShellLnk = #"
TAAAAAEUAgAAAAAAwAAAAAAAAEbfAgAAIAAAAJuvlrfNas0Bm6+Wt81qzQGAHQKo3WrNAQDwBgAAAAAAAQAAAAAAAAAAAAAAAAAAAPEBFAAfUOBP0CDqOmkQotgIACswMJ0ZAC9DOlwAAAAAAAAAA
AAAAAAAAAAAAAAAUgAxAAAAAADHQgKwMABXaW5kb3dzADwACAAEAO+++kDALMdCArAqAAAAHxAAAAAAAQAAAAAAAAAAAAAAAAAAAFcAaQBuAGQAbwB3AHMAAAAWAFYAMQAAAAAAx0JdBTAAU3lzdG
VtMzIAAD4ACAAEAO+++kDBLMdCXQUqAAAAChgAAAAAAQAAAAAAAAAAAAAAAAAAAFMAeQBzAHQAZQBtADMAMgAAABgAaAAxAAAAAAD6QKBBEABXSU5ET1d+MQAAUAAIAAQA7776QKBB+kCgQSoAAAC
HHQAAAAABAAAAAAAAAAAAAAAAAAAAVwBpAG4AZABvAHcAcwBQAG8AdwBlAHIAUwBoAGUAbABsAAAAGABKADEAAAAAALhC660UAHYxLjAAADYACAAEAO+++kCgQbhC660qAAAAiB0AAAAAAQAAAAAA
AAAAAAAAAAAAAHYAMQAuADAAAAAUAGgAMgAA8AYA+kCaGiAAcG93ZXJzaGVsbC5leGUAAEoACAAEAO+++kBXC/pAVwsqAAAA//kAAAAAAQAAAA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PowerShellLnk)))
[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell ISE.lnk", ([System.Convert]::FromBase64String($WindowsPowerShellISE)))
[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell (x86).lnk", ([System.Convert]::FromBase64String($WindowsPowerShellx86)))
[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell ISE (x86).lnk", ([System.Convert]::FromBase64String($WindowsPowerShellISEx86)))
# Trailing comment as a selection-aid for Stack Overflow readers.
Also, I have some commentary on the thread to date.
The answers that set out to reset the PSReadLine colors assume that those colors have been permanently set to non-defaults. That is unlikely because you would have to make a change to your PowerShell profile. And you would know if you changed your profile.
The other problem here is that yellow is the intended color for commands in the default PSReadLine scheme. So any reset would only give the original poster the same yellow text.
With respect to non-default colors, an easy test is to close and reopen PowerShell. If, when typing a command, the text is yellow then you're probably OK; whatever was troubling you was limited to that PowerShell session and is now gone.
If you want to check your PowerShell profile for any (permanent) Set-PSReadLineOption commands then enter
notepad $profile
into PowerShell and browse through the text file that opens. If you receive an error then you don't have a profile, (and it can't be the problem).
Edit: as pointed out by #dhobbs in the comments, this is no longer an option in PowerShell 6: https://learn.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
Stolen from Xin, but I cannot comment so you're going to have to accept that
[Console]::ResetColor()
then clear the screen to let the change take effect.
clear
I think that was the problem bucky was having with the previous answer.
Hope this helped!
Is it the ISE you are referring to? If so select Tools > Options and you will see the option to change background and foreground colour. From here you can select "Restore Defaults"
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" }
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.
You can backup colors using this facility.
https://github.com/lukesampson/concfg/blob/master/README.md
It provides wonderful preset settings that work perfectly.
I can change console background color by script:
$host.UI.RawUI.BackgroundColor = "Black"
but in this case I'm limited to preset number of defined colors and unfortunately one I'm looking for is not here. There is option to pick color from console GUI (right click on top Windows PowerShell bar->properties->Colors). Unfortunately (again) only BackGroundColor and ForeGroundColor can be changed there, no way to change one of $host.privatedata colors there.
Is there possibility to put hex coded color via script somehow?
there is a registry hack here : http://stackingcode.com/blog/2011/11/14/zenburn-powershell
In my view, Powershell should allow you to set colors to a rgb hex value rather than the predefined set of colors. But design questions aside, the way I worked around this was to create a .reg file to redefine the "color buckets" (which they call ColorTables) that Powershell uses. The code below includes comments indicating what the specific ColorTable controls in Powershell.
Notes:
To save your current colors first, open regedit and export HKCU\Console.
Save the code below to a file (e.g. colors.reg), and run it.
Create a shortcut pointing to powershell. Run it. It should have new colors.
To modify colors, set the appropriate ColorTableXX dword to the hex value, but note, the RGB values are actually BGR, and they need to be padded with 00 in front of the number. So a blue color, #4286f4, would have a dword of 00f48642.
colors.reg:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console]
; BACKGROUND
"ColorTable07"=dword:00efefef
; ERROR BACKGROUND
"ColorTable00"=dword:00efefef
;ERROR
"ColorTable12"=dword:00255ffc
; STATIC TEXT (PROMPT and OUTPUT) AND COMMAND ARGUMENT
"ColorTable01"=dword:00472713
; COMMAND TEXT
"ColorTable14"=dword:00c56e36
; COMMAND TEXT SELECTED
"ColorTable09"=dword:00ef47d3
; COMMAND FLAG
"ColorTable08"=dword:00a53733
; COMMAND FLAG SELECTED
"ColorTable15"=dword:00ef47d3
; COMMMAND ARGUMENT SELECTED
"ColorTable06"=dword:00ef47d3
; COMMAND VARIABLE (e.g. $profile)
"ColorTable10"=dword:00a53733
; COMMAND VARIABLE SELECTED
"ColorTable13"=dword:00ef47d3
; deep purple -- not sure what this is
"ColorTable04"=dword:00660566
; brown -- not sure what this is
"ColorTable05"=dword:00336699
; purple -- not sure what this is
"ColorTable11"=dword:00845f84
; green -- not sure what this is
"ColorTable02"=dword:00339933
; pastel lavendar -- not sure what this is
"ColorTable03"=dword:00FF9999