Voglio solo che PowerShell sia testo nero su sfondo bianco. Tuttavia, PowerShell v5 evidenzia i miei comandi e li rende gialli, il che è impossibile da vedere. C'è un modo per disattivare TUTTE le evidenziazioni della sintassi in PowerShell?Come disattivare l'evidenziazione della sintassi nella console?
6
A
risposta
6
La colorazione della sintassi in PowerShell v5 può essere modificata tramite Set-PSReadlineOption
. Il comando seguente imposta il colore foregound e lo sfondo dei commenti di guscio di primo piano e il colore di sfondo:
Set-PSReadlineOption -TokenKind Comment -ForegroundColor $Host.UI.RawUI.ForegroundColor -BackgroundColor $Host.UI.RawUI.BackgroundColor
o solo in bianco e nero:
Set-PSReadlineOption -TokenKind Comment -ForegroundColor Black -BackgroundColor White
Hai bisogno di fare questo per tutti i TokenKind
valori da rimuovere sintassi che colora interamente.
Se anche voi volete cambiare uscita i colori del flusso è possibile farlo tramite le proprietà PrivateData
oggetto del padrone di casa:
$Host.PrivateData.WarningForegroundColor = $Host.UI.RawUI.ForegroundColor
$Host.PrivateData.WarningBackgroundColor = $Host.UI.RawUI.BackgroundColor
...
mettere tutte queste dichiarazioni nel vostro profile per farli applicate ogni volta che si avvia PowerShell , ad esempio:
$HOME\Documents\WindowsPowerShell\profile.ps1
3
esempio, come disattivare tutti evidenziazione sintassi:
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"
0
Ecco come lo sto facendo in OSX per le cose che mi preoccupano subito:
$a = get-psreadlineoption | select ErrorBackgroundColor
$clear = $a.ErrorBackgroundColor
'command','number','operator','member' |
foreach { set-psreadlineoption $_ black $clear }
devo dire che mi piace la nuova colorazione della sintassi, ma questa risposta è utile anche per personalizzandola alle tue preferenze individuali. – marsze
Cado in situazioni in cui ho bisogno di visualizzare un esempio di codice PS sul proiettore e il proiettore ha un problema: quasi non visualizza un colore rosso. Quindi leggere la combinazione di colori predefinita diventa quasi impossibile. Con questo, ho riconfigurato la combinazione di colori in bianco e nero e che aiuto! Grazie) –