用 oh-my-posh 定制 shell 提示符

在提示符中加入 Git 状态、语言版本和路径信息。

macOSShell终端效率低风险
在 shell 配置中加入 eval "$(oh-my-posh init zsh)" 即可启用。

01命令

命令
$ eval "$(oh-my-posh init zsh)"

02作用说明

oh-my-posh 依据 JSON 或 TOML 主题渲染提示符,包含 Git 状态、运行时版本、执行耗时等分段。它是编译型二进制,速度很快,支持 PowerShell、bash、zsh 和 fish。

03风险

风险低风险
系统兼容性macOS with Homebrew installed
!注意: 每次按键都执行的提示符分段会拖慢 shell;若感觉卡顿请关闭高开销分段。

04撤销

✓无需撤销——该命令不会改变持久状态。

05来源

  • Homebrew formula: oh-my-posh
    Homebrew · vendor-doc · 2026-09-20
    依据: Prompt theme engine for any shell. Packages oh-my-posh, a prompt theme engine for many shells.
  • Official project documentation
    Official project · vendor-doc · 2026-09-20
    依据: Packages oh-my-posh, a prompt theme engine for many shells.

最后验证: 2026-09-22 · 分类: 开发者

06相关方案