跳转到主内容

更改你的命令提示符

非官方测试版翻译

本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →

技巧

如果你不清楚当前使用的是哪个 shell,Oh My Posh 提供了一个实用开关,可以告诉你答案。

oh-my-posh get shell

Edit your PowerShell profile script, you can find its location under the $PROFILE variable in your preferred PowerShell version. For example, using notepad:

notepad $PROFILE
信息

When the above command gives an error, make sure to create the profile first.

New-Item -Path $PROFILE -Type File -Force

In this scenario, it can also be that PowerShell blocks running local scripts. To solve that, set PowerShell to only require remote scripts to be signed using Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine, or sign the profile.

Add the following snippet as the last line to your PowerShell profile script:

oh-my-posh init pwsh | Invoke-Expression
Execution policy

In case the execution policy disables executing unsigned scripts on your system, you can fallback to evaluating the script instead. Use the --eval flag to do so:

oh-my-posh init pwsh --eval | Invoke-Expression

Be aware this will make initializing the shell slower.

Once added, reload your profile for the changes to take effect.

. $PROFILE