答えて

6

構文PowerShell v5の構文カラーはSet-PSReadlineOptionで変更できます。

Set-PSReadlineOption -TokenKind Comment -ForegroundColor $Host.UI.RawUI.ForegroundColor -BackgroundColor $Host.UI.RawUI.BackgroundColor 

またはちょうど黒と白::次のコマンドは、シェルの前景色と背景色にコメントforegoundと背景色を設定します

Set-PSReadlineOption -TokenKind Comment -ForegroundColor Black -BackgroundColor White 

あなたが削除するすべてのTokenKind値のためにこれを実行する必要があります完全に構文カラーリング。

あなたはまた、出力ストリームの色を変更したい場合は、ホストのPrivateDataオブジェクトのプロパティを経由してそれを行うことができます。彼らはあなたがPowerShellを起動するたびに適用され得るために

$Host.PrivateData.WarningForegroundColor = $Host.UI.RawUI.ForegroundColor 
$Host.PrivateData.WarningBackgroundColor = $Host.UI.RawUI.BackgroundColor 
... 

があなたのprofileにこれらのステートメントのすべてを入れて例えば:

$HOME\Documents\WindowsPowerShell\profile.ps1 
+0

は私が新しい構文の色分けが好きと言わなければならないが、この答えは、それをカスタマイズするためにも有用ですあなたの個人の好みに合わせて。 – marsze

+0

PSコードをプロジェクタに表示する必要があるとき、プロジェクタに問題があります。プロジェクタに問題があります。ほとんど赤色を表示しません。したがって、デフォルトの配色を読むことはほとんど不可能になります。 これで、私は黒と白の配色を再構成しました。ありがとう) –

3

例、すべてのシンタックスハイライトオフにする方法:

Set-PSReadlineOption -TokenKind Parameter -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind String -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Operator -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Type -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Variable -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Number -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Member -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Command -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Comment -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -TokenKind Keyword -ForegroundColor DarkYellow -BackgroundColor DarkMagenta 
Set-PSReadlineOption -ContinuationPromptForegroundColor DarkYellow -ContinuationPromptBackgroundColor DarkMagenta 
Set-PSReadlineOption -EmphasisForegroundColor DarkYellow -EmphasisBackgroundColor DarkMagenta 
Set-PSReadlineOption -ErrorForegroundColor DarkYellow -ErrorBackgroundColor DarkMagenta 

(Get-Host).PrivateData.ErrorForegroundColor="DarkYellow" 
(Get-Host).PrivateData.ErrorBackgroundColor="DarkMagenta" 
(Get-Host).PrivateData.WarningForegroundColor="DarkYellow" 
(Get-Host).PrivateData.WarningBackgroundColor="DarkMagenta" 
(Get-Host).PrivateData.DebugForegroundColor="DarkYellow" 
(Get-Host).PrivateData.DebugBackgroundColor="DarkMagenta" 
(Get-Host).PrivateData.VerboseForegroundColor="DarkYellow" 
(Get-Host).PrivateData.VerboseBackgroundColor="DarkMagenta" 
(Get-Host).PrivateData.ProgressForegroundColor="DarkYellow" 
(Get-Host).PrivateData.ProgressBackgroundColor="DarkMagenta" 
をここで

See screenshot (Windows10)

0

は、私はすぐに私を気にもののためOSXでそれをやっている方法は次のとおりです。

$a = get-psreadlineoption | select ErrorBackgroundColor 
$clear = $a.ErrorBackgroundColor 

'command','number','operator','member' | 
foreach { set-psreadlineoption $_ black $clear } 
関連する問題