How can I change the color of string values I type? - powershell

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' }

Related

How to change iPython error highlighting color

I'm using IPython with iterm2 in macOS. I had never had issues before with the color scheme, but this time when an exception occurs, it highlights certain parts in a color combination that I find very hard to read. I've tried with different color setups in iterm and also adjusting highlighting_style and colors in the ipython_config.py file, without much luck. I've seen there is an option to set specific colors highlighting_style_overrides but I haven't been lucky finding the right pygments option for this.
See Position below. This is the best contrast setup I've achieved, I still find hard it to read without focusing.
There is an open issue regarding this: https://github.com/ipython/ipython/issues/13446
Here is the commit which introduced this change:
https://github.com/ipython/ipython/commit/3026c205487897f6874b2ff580fe0be33e36e033
To get the file path on your system, run the following:
import IPython, os
os.path.join(os.path.dirname(IPython.__file__), 'core/ultratb.py')
Finally, open the file and look for:
style = stack_data.style_with_executing_node(style, "bg:ansiyellow")
For the time being, you can manually patch it by changing bg:ansiyellow to something that works best given your color scheme, e.g. bg:ansired or bg:#ff0000.
Here's an option you can drop in your ipython_config.py to duck punch in a better background color:
try:
from IPython.core import ultratb
ultratb.VerboseTB._tb_highlight = "bg:ansired"
except Exception:
print("Error patching background color for tracebacks, they'll be the ugly default instead")
Verified to work with IPython version 8.7.0

Fish autocomplete pager doesn't highlight options when tabbing through them

Previously, fish would highlight the currently selected autocomplete. Now it doesn't. Do you know how to make it highlight it?
Observed behavior
Expected behavior
The selected background color is stored in $fish_pager_color_selected_background, or $fish_color_search_match if that isn't set.
It seems either these aren't set, or the value you chose looks like your terminal's background. Given that you now have a light background and fish has no way to detect it that's hard to avoid.
Use something like
set -g fish_pager_color_selected_background --background=533
to set it. The value should look like arguments to fish's set_color builtin.
See https://fishshell.com/docs/current/interactive.html#pager-color-variables for more information.

Powershell quotes are not visible on the screen

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.

Programmatically change PowerShell's 16 default console colours

PowerShell improves on the (frankly) fugly Windows Console colour scheme by assigning a bluish value to one of its 16 console colours ( - the one known as DarkMagenta for some reason - ), and uses this as the default screen background.
I want to programmatically change each of the 16 colours to a custom colour scheme. In my PowerShell profile, for example.
I've found explanations on how to change which one of the ConsoleHost's 16 colours gets assigned to different kinds of text, but what I want is to actually change each of the ConsoleHost's 16 colours to a different hex value. (For myself only, not for other users, or other consoles, such as cmd.exe.)
Of course this can be done by right-clicking the menu bar and manually adjusting the "Properties" or "Default" settings, but this gets very quickly tiring. And I cannot locate where these settings get persisted.
(I have already searched the registry and C:\Users\<current_user>\AppData, and found nothing, except for the ColorTable## properties under HKCU:\Console, whose scope is obviously broader than the PowerShell console settings.)
If anyone can help, it would be greatly appreciated.
The console colors are defined in multiple places:
Global/Default: HKCU:\Console. This applies to all conhost.exe-applications including cmd.exe and powershell.exe.
Per process: HKCU:\Console\<PROCESS_PATH_WITH_UNDESCORE> for process-specific changes. Ex. HKEY_CURRENT_USER\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe is defined and has modified ColorTable05 and ColorTable06.
Per shortcut: Inside the shortcut (.lnk). This is hard to modify programmatically, would probably require P\Invoke.
You can modify the process-level values with PS using:
Set-ItemProperty -Path "HKCU:\Console\%SystemRoot%_System32_WindowsPowerShell_v1.0_powershell.exe" -Name ColorTable04 -Value 5645313
Be aware that to see the values of the process-level you need start PS using run, windows explorer etc. If you use one of the shortcuts, then the shortcut's values will be used. So it might be easier to modify the shortcut and keep a copy of it for new setups.
Each "ColorTable" has a name hardcoded in the System.ConsoleColor-enum, so it's just "random" that they used the one called DarkMagneta. Probably because it's a unique color that isn't used that much.
I searched for "change powershell console color" and found tons of examples.
Perhaps this is what you are looking for:
How can I set the PowerShell console background color
$Host.UI.RawUI.BackgroundColor = ($bckgrnd = 'DarkBlue')
$Host.UI.RawUI.ForegroundColor = 'White'
$Host.PrivateData.ErrorForegroundColor = 'Red'
$Host.PrivateData.ErrorBackgroundColor = $bckgrnd
$Host.PrivateData.WarningForegroundColor = 'Magenta'
$Host.PrivateData.WarningBackgroundColor = $bckgrnd
$Host.PrivateData.DebugForegroundColor = 'Yellow'
$Host.PrivateData.DebugBackgroundColor = $bckgrnd
$Host.PrivateData.VerboseForegroundColor = 'Green'
$Host.PrivateData.VerboseBackgroundColor = $bckgrnd
$Host.PrivateData.ProgressForegroundColor = 'Cyan'
$Host.PrivateData.ProgressBackgroundColor = $bckgrnd
Clear-Host
There is also another discussion on the topic at:
Setting Powershell colors with hex values in profile script
I have made a utility for Windows console colors called Concfg.
It can import colours from JSON preset files, and takes care of removing the overrides from the registry and .lnk files.

How can I reset the powershell colors

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+Wt81qzQGAHQKo3WrNAQDwBgAAAAAAAQAAAAAAAAAAAAAAAAAAAPEBFAAfUOBP0CDqOmkQotgIACswMJ0ZAC9DOlwAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
"#
# Decode and save to file.
[System.IO.File]::WriteAllBytes("$pwd\Windows PowerShell.lnk", ([System.Convert]::FromBase64String($windowsPowerShellLnk)))
[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.