밝은 색 테마 구성

어두운 배경 터미널에 대해 PowerShell 및 PSReadLine 의 기본 색이 선택됩니다. 그러나 일부 사용자는 어두운 텍스트로 밝은 배경을 사용하도록 선택할 수 있습니다. 대부분의 기본 색은 배경을 설정하지 않으므로 밝은 배경에 밝은 전경색을 사용하면 읽을 수 없는 텍스트가 생성됩니다.

PowerShell 7.2부터 PowerShell은 기본 콘솔 환경에 색이 지정된 출력을 추가합니다. Windows PowerShell에서는 이 $PSStyle 기능을 기본적으로 사용할 수 없습니다. 그러나 PowerShell 갤러리의 PSStyle 모듈을 사용하여 이 문서에 설명된 것과 동일한 기술을 사용하여 색 값을 설정할 수 있습니다.

사용되는 색은 변수에 $PSStyle 정의되며 어두운 배경을 위해 설계되었습니다. 밝은 배경 터미널에서 더 잘 작동하도록 이러한 색을 변경할 수 있습니다.

PSReadLine 을 사용하면 18가지 구문 요소에 대한 색을 정의할 수 있습니다. cmdlet을 사용하여 Get-PSReadLineOption 현재 설정을 볼 수 있습니다.

EditMode                               : Windows
AddToHistoryHandler                    : System.Func`2[System.String,System.Object]
HistoryNoDuplicates                    : True
HistorySavePath                        : C:\Users\user1\AppData\Roaming\Microsoft\Wind...
HistorySaveStyle                       : SaveIncrementally
HistorySearchCaseSensitive             : False
HistorySearchCursorMovesToEnd          : False
MaximumHistoryCount                    : 4096
ContinuationPrompt                     : >>
ExtraPromptLineCount                   : 0
PromptText                             : {> }
BellStyle                              : Audible
DingDuration                           : 50
DingTone                               : 1221
CommandsToValidateScriptBlockArguments : {ForEach-Object, %, Invoke-Command, icm...}
CommandValidationHandler               :
CompletionQueryItems                   : 100
MaximumKillRingCount                   : 10
ShowToolTips                           : True
ViModeIndicator                        : None
WordDelimiters                         : ;:,.[]{}()/\|^&*-=+'"-—―
AnsiEscapeTimeout                      : 100
PredictionSource                       : HistoryAndPlugin
PredictionViewStyle                    : InlineView
CommandColor                           : "`e[93m"
CommentColor                           : "`e[32m"
ContinuationPromptColor                : "`e[37m"
DefaultTokenColor                      : "`e[37m"
EmphasisColor                          : "`e[96m"
ErrorColor                             : "`e[91m"
InlinePredictionColor                  : "`e[38;5;238m"
KeywordColor                           : "`e[92m"
ListPredictionColor                    : "`e[33m"
ListPredictionSelectedColor            : "`e[48;5;238m"
MemberColor                            : "`e[97m"
NumberColor                            : "`e[97m"
OperatorColor                          : "`e[90m"
ParameterColor                         : "`e[90m"
SelectionColor                         : "`e[30;47m"
StringColor                            : "`e[36m"
TypeColor                              : "`e[37m"
VariableColor                          : "`e[92m"

색 설정은 터미널에서 색을 변경하는 ANSI 이스케이프 시퀀스를 포함하는 문자열로 저장됩니다. cmdlet을 Set-PSReadLineOption 사용하면 밝은 색 배경에 더 잘 작동하는 값으로 색을 변경할 수 있습니다.

밝은 테마의 색 정의

편집기와 콘솔 창 모두에 밝은 테마를 사용하도록 PowerShell ISE를 구성할 수 있습니다. ISE가 다양한 구문 및 출력 형식에 사용하는 색을 보고 변경할 수도 있습니다. 이러한 색 선택을 사용하여 PSReadLine에 대해 유사한 테마를 정의할 수 있습니다.

다음 해시 테이블은 PowerShell ISE의 색을 모방하는 PSReadLine 의 색을 정의합니다.

$ISETheme = @{
    Command                  = $PSStyle.Foreground.FromRGB(0x0000FF)
    Comment                  = $PSStyle.Foreground.FromRGB(0x006400)
    ContinuationPrompt       = $PSStyle.Foreground.FromRGB(0x0000FF)
    Default                  = $PSStyle.Foreground.FromRGB(0x0000FF)
    Emphasis                 = $PSStyle.Foreground.FromRGB(0x287BF0)
    Error                    = $PSStyle.Foreground.FromRGB(0xE50000)
    InlinePrediction         = $PSStyle.Foreground.FromRGB(0x93A1A1)
    Keyword                  = $PSStyle.Foreground.FromRGB(0x00008b)
    ListPrediction           = $PSStyle.Foreground.FromRGB(0x06DE00)
    Member                   = $PSStyle.Foreground.FromRGB(0x000000)
    Number                   = $PSStyle.Foreground.FromRGB(0x800080)
    Operator                 = $PSStyle.Foreground.FromRGB(0x757575)
    Parameter                = $PSStyle.Foreground.FromRGB(0x000080)
    String                   = $PSStyle.Foreground.FromRGB(0x8b0000)
    Type                     = $PSStyle.Foreground.FromRGB(0x008080)
    Variable                 = $PSStyle.Foreground.FromRGB(0xff4500)
    ListPredictionSelected   = $PSStyle.Background.FromRGB(0x93A1A1)
    Selection                = $PSStyle.Background.FromRGB(0x00BFFF)
}

비고

이 메서드를 FromRGB() 사용하여 원하는 색에 대한 ANSI 이스케이프 시퀀스를 만들 수 있습니다. $PSStyle대한 자세한 내용은 about_ANSI_Terminals참조하세요. ANSI 이스케이프 시퀀스에 대한 자세한 내용은 Wikipedia의 ANSI 이스케이프 코드 문서를 참조하세요.

프로필에서 색 테마 설정

모든 PowerShell 세션에서 원하는 색 설정을 사용하려면 구성 설정을 PowerShell 프로필 스크립트에 추가해야 합니다. 예제는 셸 환경 사용자 지정을 참조하세요.

$ISETheme 변수와 다음 Set-PSReadLineOption 명령을 프로필에 추가합니다.

Set-PSReadLineOption -Colors $ISETheme

다음 설정은 밝은 배경 터미널에 더 적합합니다.

$PSStyle.Formatting.FormatAccent       = $PSStyle.Foreground.Green
$PSStyle.Formatting.TableHeader        = $PSStyle.Foreground.Green
$PSStyle.Formatting.ErrorAccent        = $PSStyle.Foreground.Cyan
$PSStyle.Formatting.Error              = $PSStyle.Foreground.Red
$PSStyle.Formatting.Warning            = $PSStyle.Foreground.Yellow
$PSStyle.Formatting.Verbose            = $PSStyle.Foreground.Yellow
$PSStyle.Formatting.Debug              = $PSStyle.Foreground.Yellow
$PSStyle.Progress.Style                = $PSStyle.Foreground.Yellow
$PSStyle.FileInfo.Directory            = $PSStyle.Background.FromRgb(0x2f6aff) +
                                         $PSStyle.Foreground.BrightWhite
$PSStyle.FileInfo.SymbolicLink         = $PSStyle.Foreground.Cyan
$PSStyle.FileInfo.Executable           = $PSStyle.Foreground.BrightMagenta
$PSStyle.FileInfo.Extension['.ps1']    = $PSStyle.Foreground.Cyan
$PSStyle.FileInfo.Extension['.ps1xml'] = $PSStyle.Foreground.Cyan
$PSStyle.FileInfo.Extension['.psd1']   = $PSStyle.Foreground.Cyan
$PSStyle.FileInfo.Extension['.psm1']   = $PSStyle.Foreground.Cyan

접근성을 위한 색 선택

색맹 또는 색을 보는 기능을 제한하는 기타 조건을 가진 사용자에게는 ISE 색 테마가 작동하지 않을 수 있습니다.

W3C(World Wide Web 컨소시엄)에는 접근성을 위해 색을 사용하기 위한 권장 사항이 있습니다. WCAG(웹 콘텐츠 접근성 지침) 2.1에서는 "텍스트 및 텍스트 이미지의 시각적 프레젠테이션의 대비 비율이 4.5:1 이상"을 권장합니다. 자세한 내용은 성공 기준 1.4.3 대비(최소)를 참조하세요.

대비 비율 웹 사이트에서는 전경색과 배경색을 선택하고 대비를 측정할 수 있는 도구를 제공합니다. 이 도구를 사용하여 가장 적합한 색 조합을 찾을 수 있습니다.