※エディタではなくて統合ターミナルの話です。
シンタックスハイライトどころか Write-Host -ForegroundColor
等の色指定もすべて効かない。
これの直し方がなかなか見つからなくて時間食ったのでメモ。
原因
You can fix it by changing environment variable TERM from xterm-256color to xterm
No colors in powershell-6.0.4 on Fedora 28 - just black/white · Issue #7511 · PowerShell/PowerShell
https://github.com/PowerShell/PowerShell/issues/7511#issuecomment-412521213
Visual Studio Codeの統合ターミナルでも確かにTERM
がxterm-256color
になっていた。
設定
どうもpwshを起動したあとでは遅いらしく、profile.ps1
で設定しても効かない。Visual Studio Codeで最初に起動するシェルをpwshにしている自分はterminal.integrated.env.linux
も効かず。
仕方がないのでシェルのパスを/usr/bin/env
にしてTERM注入。
settings.json
"terminal.integrated.shell.linux": "/usr/bin/env",
"terminal.integrated.shellArgs.linux": ["TERM=xterm", "/usr/bin/pwsh"],