Oh My Posh Documentation

website·Indexed 36 days ago

https://ohmyposh.dev/

A customizable and fast prompt theme engine for any shell that renders themed prompts.

Tokens
984
Snippets
6
Records
7
Agent score
23%

What's inside Oh My Posh

  1. Install Oh My Posh on Windows, macOS, or Linux

    Oh My Posh is a cross-platform prompt theme engine. Use the following commands based on your operating system to install it.
    # Windows
    winget install JanDeDobbeleer.OhMyPosh --source winget
    # macOS
    brew install jandedobbeleer/oh-my-posh/oh-my-posh
    
    # Linux
    curl -s https://ohmyposh.dev/install.sh | bash -s
  2. Troubleshoot common Oh My Posh issues

    Common issues and their resolutions:

    • Icons appear as boxes: Install a Nerd Font and set it in your terminal emulator.
    • oh-my-posh command not found: Restart your terminal or manually add the installation directory to your system's $PATH.
    • PowerShell execution policy error: Run Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine.
    • Fish/Nu version errors: Ensure Fish is 4.1.0+ and Nushell is v0.104.0+.
    • macOS bash errors: Update bash using brew install bash.
  3. Apply and manage Oh My Posh themes

    You can apply built-in themes during initialization or export a theme to a local file for custom editing. Use the reload command to see changes in real-time while editing your configuration file.
    # Apply a theme in PowerShell
    oh-my-posh init pwsh --config 'jandedobbeleer' | Invoke-Expression
    # Apply a theme in Bash/Zsh
    eval "$(oh-my-posh init bash --config jandedobbeleer)"
    
    # Export a theme for editing
    oh-my-posh config export --config jandedobbeleer --output ~/.mytheme.omp.json
    
    # Enable live reload during editing
    oh-my-posh enable reload
  4. Install and configure Nerd Fonts for Oh My Posh

    Oh My Posh themes require Nerd Fonts to render glyphs and icons correctly. You can install a supported font directly via the CLI. After installation, you must manually set the font in your terminal emulator's settings. Meslo LGM NF is the recommended font.
    # Install a specific font (e.g., meslo)
    oh-my-posh font install meslo
    
    # List all installable fonts
    oh-my-posh font list
  5. Integrate Oh My Posh with your shell

    To activate Oh My Posh, add the appropriate initialization line to your shell's profile configuration file. You can detect your current shell using oh-my-posh get shell.
    # PowerShell ($PROFILE)
    oh-my-posh init pwsh | Invoke-Expression
    # Bash (~/.bashrc)
    eval "$(oh-my-posh init bash)"
    
    # Zsh (~/.zshrc)
    eval "$(oh-my-posh init zsh)"
    
    # Fish (~/.config/fish/config.fish)
    oh-my-posh init fish | source
    
    # Nu ($nu.config-path)
    oh-my-posh init nu
    
    # Elvish (~/.elvish/rc.elv)
    eval (oh-my-posh init elvish)
    
    # Xonsh (~/.xonshrc)
    execx($(oh-my-posh init xonsh))
  6. Validate Oh My Posh configurations via MCP API

    Oh My Posh provides an MCP endpoint for validating configurations and segments using JSON-RPC 2.0 over HTTP POST. Supported formats are json, yaml, toml, and auto.
    curl -X POST https://ohmyposh.dev/api/mcp \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","method":"tools/call","params":{"name":"validate_config","arguments":{"content":"{\"version\":3}","format":"json"}},"id":1}'
  7. Create a custom Oh My Posh configuration

    Oh My Posh configurations use JSON, YAML, or TOML. The configuration is structured around blocks, which contain segments. Each segment has a type (e.g., path, git, node) that determines what information is displayed.

    Top-level fields include:

    • version: Schema version (currently 3).
    • blocks: Array of prompt blocks.
    • final_space: Space at the end of the prompt.
    • console_title_template: Template for the terminal window title.
    • transient_prompt: Configuration for transient prompts.
    • secondary_prompt: Configuration for the secondary prompt.
    • palette: Custom color definitions.
    • cycle: Cycling configuration.
    {
      "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
      "version": 3,
      "blocks": [
        {
          "type": "prompt",
          "alignment": "left",
          "segments": [
            {
              "type": "path",
              "style": "powerline",
              "powerline_symbol": "\ue0b0",
              "foreground": "#ffffff",
              "background": "#61afef",
              "properties": { "style": "folder" }
            }
          ]
        }
      ]
    }