Configs2026年5月19日·1 分钟阅读

Oh My Posh — Cross-Platform Customizable Shell Prompt Engine

A prompt theme engine that works with any shell on any OS, rendering rich segments for Git, language versions, cloud context, and system status using Nerd Font icons.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 96/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Prompt
安装
Single
信任
信任等级:Established
入口
Oh My Posh
通用 CLI 安装命令
npx tokrepo install 5dbe8e9e-539f-11f1-9bc6-00163e2b0d79

Introduction

Oh My Posh is a shell-agnostic prompt renderer that transforms the terminal prompt into an informative, visually rich status line. It displays Git branch and status, language runtime versions, Kubernetes context, execution time, and dozens of other segments. Written in Go, it runs on Bash, Zsh, Fish, PowerShell, cmd, and Nushell across macOS, Linux, and Windows.

What Oh My Posh Does

  • Renders a fully customizable prompt for any shell on any operating system
  • Displays segments for Git status, Node/Python/Go/Rust versions, cloud context, and more
  • Supports 100+ built-in themes with live preview via the theme browser
  • Uses Nerd Font glyphs for icons, separators, and powerline-style segments
  • Provides a configuration-driven approach using JSON, YAML, or TOML theme files

Architecture Overview

Oh My Posh is a single Go binary that the shell calls before rendering each prompt. It reads a theme configuration file that defines segments, colors, and layout. Each segment is a Go module that queries system state (Git repo, environment variables, running processes) and formats output. The engine supports primary, secondary, and transient prompts, plus right-aligned segments. Rendering targets ANSI escape sequences compatible with all modern terminal emulators.

Self-Hosting & Configuration

  • Install via Homebrew, winget, Scoop, or direct download from GitHub releases
  • Add the eval or oh-my-posh init line to your shell's RC file
  • Choose a theme from the built-in gallery or create a custom .omp.json file
  • Enable specific segments by adding them to the theme config with their properties
  • Use oh-my-posh debug to troubleshoot segment detection and rendering issues

Key Features

  • Works identically across Bash, Zsh, Fish, PowerShell, cmd, and Nushell
  • 100+ community themes with a visual browser at ohmyposh.dev
  • Tooltips that appear contextually when specific tools are detected
  • Transient prompt support to keep scrollback clean
  • Extensible with custom segments via shell commands or HTTP endpoints

Comparison with Similar Tools

  • Starship — Rust-based cross-shell prompt; Oh My Posh offers more theming depth and segment options
  • Powerlevel10k — Zsh-only prompt theme; Oh My Posh works across all shells and OS platforms
  • Pure — minimalist Zsh prompt; Oh My Posh provides richer information density
  • Oh My Zsh — Zsh framework with prompt themes; Oh My Posh is shell-agnostic and standalone
  • Tide — Fish-specific prompt; Oh My Posh brings comparable features to every shell

FAQ

Q: Do I need Nerd Fonts installed? A: Themes that use icons require a Nerd Font patched terminal font. Minimal themes work without them.

Q: Does it slow down my shell? A: Prompt rendering typically takes 20-50ms. The --debug flag shows timing per segment for optimization.

Q: Can I use it alongside Oh My Zsh? A: Yes. Oh My Posh replaces only the prompt theme; Oh My Zsh plugins and aliases continue to work.

Q: How do I create a custom theme? A: Copy an existing .omp.json file and modify segments, colors, and icons. The documentation covers every segment property.

Sources

讨论

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

相关资产