Microsoft has released a new program called Windows Terminal which provides updated functionality for command line users. It is only for Windows 10 and can be downloaded from the Windows Store.
It allows for having multiple tabs open in a single window, each with a console inside of it.
The tabs can run different console programs, such as cmd or Powershell.
A file named profiles.json governs the various settings, mainly color and font. However, this has serious shortcomings when it comes to Powershell’s internal command line syntax highlighting.
You must use a custom Powershell profile script to make the syntax highlighting look good with your color scheme, because this type of configuration is specific to Powershell, and not to Windows Terminal.
This tutorial will get you setup with the color scheme that I am using, which resembles the Uranium stylesheet included with Fractorium. You can then customize it further as needed.
In your profile for Powershell in profiles.jason, add these lines:
“commandline”: “powershell.exe”,
“colorScheme”: “Campbell Powershell”,
“foreground”: “#7CE800”,
“background”: “#706F77”,
Make a file named profile.ps1 in C:\Users\[USERNAME]\Documents\WindowsPowerShell and place the following text in it:
#This profile script should reside at $PROFILE.CurrentUserAllHosts and can be reloaded by running> & $PROFILE.CurrentUserAllHosts
Add-Type -AssemblyName System.Drawing
#The background/foreground colors never seem to work. They get cleared after the first command prints any text.
#So we comment them out and leave them here in case a future version of Powershell fixes this bug.
#$foregrnd = [System.ConsoleColor]::Green
#$bckgrnd = [System.ConsoleColor]::Gray
#$Host.UI.RawUI.ForegroundColor = $foregrnd
#$Host.UI.RawUI.BackgroundColor = $bckgrnd
#These seem to work, but don't really offer any value.
#$Host.PrivateData.ErrorForegroundColor = 'Cyan'
#$Host.PrivateData.ErrorBackgroundColor = $bckgrnd
#$Host.PrivateData.WarningForegroundColor = 'Cyan'
#$Host.PrivateData.WarningBackgroundColor = $bckgrnd
#$Host.PrivateData.DebugForegroundColor = 'Cyan'
#$Host.PrivateData.DebugBackgroundColor = $bckgrnd
#$Host.PrivateData.VerboseForegroundColor = 'Cyan'
#$Host.PrivateData.VerboseBackgroundColor = $bckgrnd
#$Host.PrivateData.ProgressForegroundColor = 'Cyan'
#$Host.PrivateData.ProgressBackgroundColor = $bckgrnd
$attributecolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::LightSteelBlue.ToArgb()))
$commandcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::Yellow.ToArgb()))
$argumentcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::SandyBrown.ToArgb())) #Doesn't seem to work.
$parametercolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::LightBlue.ToArgb()))
$commentcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::PaleGreen.ToArgb()))
$groupendcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::DarkGoldenrod.ToArgb())) #Doesn't seem to work.
$groupstartcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::DarkGoldenrod.ToArgb())) #Doesn't seem to work.
$keywordcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::DarkOrange.ToArgb()))
$linecontinuationcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::WhiteSmoke.ToArgb())) #Doesn't seem to work.
$looplabelcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::AntiqueWhite.ToArgb()))
$membercolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::LightGoldenrodYellow.ToArgb()))
$numbercolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::Violet.ToArgb()))
$operatorcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::LightSkyBlue.ToArgb()))
$statementseparatorcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::WhiteSmoke.ToArgb())) #Doesn't seem to work.
$stringcolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::Salmon.ToArgb()))
$typecolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::Gold.ToArgb()))
$variablecolor = [System.Drawing.ColorTranslator]::ToHtml([System.Drawing.Color]::FromArgb([System.Drawing.Color]::MediumAquamarine.ToArgb()))
Set-PSReadLineOption -Colors @{Attribute = $attributecolor }
Set-PSReadLineOption -Colors @{Command = $commandcolor }
Set-PSReadLineOption -Colors @{Argument = $argumentcolor }
Set-PSReadLineOption -Colors @{Parameter = $parametercolor }
Set-PSReadLineOption -Colors @{Comment = $commentcolor }
Set-PSReadLineOption -Colors @{GroupEnd = $groupendcolor }
Set-PSReadLineOption -Colors @{GroupStart = $groupstartcolor }
Set-PSReadLineOption -Colors @{Keyword = $keywordcolor }
Set-PSReadLineOption -Colors @{LineContinuation = $linecontinuationcolor }
Set-PSReadLineOption -Colors @{LoopLabel = $looplabelcolor }
Set-PSReadLineOption -Colors @{Member = $membercolor }
Set-PSReadLineOption -Colors @{Number = $numbercolor }
Set-PSReadLineOption -Colors @{Operator = $operatorcolor }
Set-PSReadLineOption -Colors @{StatementSeparator = $statementseparatorcolor }
Set-PSReadLineOption -Colors @{String = $stringcolor }
Set-PSReadLineOption -Colors @{Type = $typecolor }
Set-PSReadLineOption -Colors @{Variable = $variablecolor }
After adding this text, you will notice a few things.
1) Setting the Powershell background and foreground text does not seem to work correctly and is very buggy. So it will only show the foreground and background colors you set in profiles.json.
2) Some of the token colors don’t seem to actually get set, and the inline comments specify which ones.
3) A comment at the top showing the command to use to reload the profile from within a Terminal that is already running.
You now will have nicely colored command line tokens within Powershell, and can change them to suit your tastes as needed.