1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Windows の PowerShell で Oh My Posh が有効にならない場合、日本語ユーザー名が悪さをしているかも

Last updated at Posted at 2022-03-14

はじめに

PC が新しくなったので、チュートリアル: Oh My Posh を使用して PowerShell または WSL のカスタム プロンプトをセットアップする を参照しながら Oh My Posh をインストールしていたら、Set-PoshPrompt の実行に失敗した。

PS C:\> Set-PoshPrompt -Theme paradox
&: The term 'C:/Users/譚牙アア豢倶ク/AppData/Local/oh-my-posh/oh-my-posh.exe' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Invoke-Expression: Cannot bind argument to parameter 'Command' because it is an empty string.

もちろん?、Get-PoshTemes コマンドレットも失敗する。

PS C:\> Get-PoshThemes
Get-PoshThemes: The term 'Get-PoshThemes' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

回避方法

どうやら、日本語ユーザー名があるせいでパスの解決に失敗している模様。

Oh My Posh の FAQ を見ると解決方法が乗っていた

エンコーディングを UTF-8 にすればよいらしい。

$OutputEncoding = [console]::InputEncoding = [console]::OutputEncoding = New-Object System.Text.UTF8Encoding

この状態で、もう一度 Oh My Posh をインストールすれば、Set-PoshPromptGet-PoshThemes が実行できるようになる。

image.png

おわりに

日本語のユーザー名はまだまだ引っかかるところがありますね。

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?