PoshCode Archive  Artifact Content

Artifact b62074ba0bd0987ffc275cf598f83e94e5019d6adb6efdbf0b2673cd2598df45:

  • File VS-PS-Tools-Dark.ps1 — part of check-in [53da4015a1] at 2018-06-10 13:43:42 on branch trunk — If you use the dark color scheme in VS, you’ll find that the powershell tools syntax highlighting is unusable. While it is possible to update the colors by hand in visual studio’s options, this is a pain in the ass. Here’s a script to run in the NuGet console that will set the token colors to something usable. The scheme is persistent. (user: Oisin Grehan size: 2067)

# encoding: ascii
# api: powershell
# title: VS PS Tools Dark
# description: If you use the dark color scheme in VS, you’ll find that the powershell tools syntax highlighting is unusable. While it is possible to update the colors by hand in visual studio’s options, this is a pain in the ass. Here’s a script to run in the NuGet console that will set the token colors to something usable. The scheme is persistent.
# version: 0.1
# type: function
# author: Oisin Grehan
# license: CC0
# function: get-color
# x-poshcode-id: 4609
# x-archived: 2015-07-24T21:12:55
# x-published: 2015-11-15T03:16:00
#
#
# pstools.ps1

<#
function get-color {
    $cdlg = new-object system.windows.forms.colordialog
    if ($cdlg.showdialog() -eq "OK") {
        $cdlg.color
    }
    $cdlg.dispose()
}
#>

# PASTE FROM HERE DOWN INTO NUGET PACKAGE MANAGER CONSOLE
$map = @{}
$map['PowerShell Attribute'] = [System.Drawing.Color]'#FFB0C4DE'
$map['PowerShell Command'] = [System.Drawing.Color]'#FFE0FFFF'
$map['PowerShell Command Argument'] = [System.Drawing.Color]'#FFEE82EE'
$map['PowerShell Command Parameter'] = [System.Drawing.Color]'#FFFFE4B5'
$map['PowerShell Comment'] = [System.Drawing.Color]'#FF98FB98'
$map['PowerShell Keyword'] = [System.Drawing.Color]'#FFE0FFFF'
$map['PowerShell Number'] = [System.Drawing.Color]'#FFFFE4C4'
$map['PowerShell Operator'] = [System.Drawing.Color]'#FFD3D3D3'
$map['PowerShell String'] = [System.Drawing.Color]'#FFDB7093'
$map['PowerShell Type'] = [System.Drawing.Color]'#FF8FBC8F'
$map['PowerShell Variable'] = [System.Drawing.Color]'#FFFF4500'
$map['PowerShell Member'] = [System.Drawing.Color]'#FFF5F5F5'
$map['PowerShell Group End'] = [System.Drawing.Color]'#FFF5F5F5'
$map['PowerShell Group Start'] = [System.Drawing.Color]'#FFF5F5F5'

# set powershell tools token color scheme
$tokens = $dte.Properties("FontsAndColors", "TextEditor").Item("FontsAndColorsItems").object
$tokens | ? name -like "PowerShell *" | % { $_.Foreground = [system.drawing.colortranslator]::ToOle($map[$_.name]) }