Scripts2026年7月16日·1 分钟阅读

oh-my-posh — Cross-Platform Prompt Theme Engine

Customizable prompt theme engine for any shell on any OS, with 100+ built-in themes, Git status, and language segment support.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 96/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Prompt
安装
Single
信任
信任等级:Established
入口
oh-my-posh Overview
直接安装命令
npx -y tokrepo@latest install 91da5dfd-8135-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

oh-my-posh is a cross-platform prompt theme engine that works with Bash, Zsh, Fish, PowerShell, cmd, and Nushell on Linux, macOS, and Windows. It renders rich prompt segments showing Git status, language versions, cloud contexts, and execution time using a single JSON or YAML configuration file.

What oh-my-posh Does

  • Renders customizable prompt segments for Git status, language versions, and cloud contexts
  • Ships with 100+ community themes that work across all supported shells
  • Supports Nerd Font icons, Unicode glyphs, and emoji in prompt segments
  • Shows execution time, exit codes, battery level, and system information
  • Configures via a single JSON, YAML, or TOML file shared across shells

Architecture Overview

oh-my-posh is a compiled Go binary that shells invoke as an external command during prompt rendering. The binary reads a theme configuration file, evaluates each segment (Git, Node, Python, AWS, etc.) by inspecting the current environment, and emits ANSI-escaped strings that the shell displays. Because it runs as an external process, it works identically across all supported shells without shell-specific plugins.

Setup & Configuration

  • Install via Homebrew, Winget, Scoop, or download the binary directly
  • Initialize in your shell profile with eval "$(oh-my-posh init <shell>)"
  • Point --config to a local file or remote URL for your theme
  • Customize segments by editing the JSON/YAML theme file
  • Install a Nerd Font for icon rendering: oh-my-posh font install

Key Features

  • Works on every major shell and operating system with one binary
  • 100+ built-in themes with instant preview via the documentation site
  • Segments for 50+ tools: Git, Docker, Kubernetes, AWS, Python, Node, Rust, and more
  • Transient prompt support to clean up previous prompts after execution
  • Tooltip segments that appear contextually based on the current command

Comparison with Similar Tools

  • Starship — Rust-based, minimal by default; oh-my-posh offers richer theming and more segments
  • Powerlevel10k — Zsh-only with instant prompt; oh-my-posh is cross-shell and cross-platform
  • Pure — Zsh-only minimalist prompt; oh-my-posh provides full customization
  • Agnoster — single theme, oh-my-posh ships 100+ themes and custom segment support

FAQ

Q: Does oh-my-posh slow down my shell? A: Prompt rendering typically takes 20-50ms. Disable heavy segments like Git in large repos if latency is noticeable.

Q: Can I use oh-my-posh with Windows Terminal? A: Yes. It works with Windows Terminal, ConEmu, Alacritty, and any terminal that supports ANSI escape codes.

Q: Do I need a Nerd Font? A: Nerd Fonts are recommended for icon rendering. Without one, you can use Unicode-only themes or plain text segments.

Q: Can I share one config across Bash, Zsh, and PowerShell? A: Yes. The same JSON/YAML theme file works across all shells since oh-my-posh is shell-agnostic.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产