LoginSignup
0
0

More than 5 years have passed since last update.

LinuxのVisual Studio Codeでpwshのシンタックスハイライトが効かない件の対策

Last updated at Posted at 2018-09-01

※エディタではなくて統合ターミナルの話です。

シンタックスハイライトどころか 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の統合ターミナルでも確かにTERMxterm-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"],

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0