Appearance
Oh My Posh - Cross-Platform Prompt Engine
Oh My Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable. It's designed to be fast, extensible, and cross-platform, with particular strength on Windows PowerShell and Windows Terminal. Oh My Posh provides beautiful themes, extensive customization options, and seamless integration across different operating systems and shells.
Installation
Windows Installation
PowerShell (Recommended)
powershell
# Install via PowerShell Gallery
Install-Module oh-my-posh -Scope CurrentUser
# Install via Winget
winget install JanDeDobbeleer.OhMyPosh
# Install via Chocolatey
choco install oh-my-posh
# Install via Scoop
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json
Manual Installation
powershell
# Download and install manually
Invoke-WebRequest -Uri "https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-windows-amd64.exe" -OutFile "$env:USERPROFILE\oh-my-posh.exe"
# Add to PATH
$env:PATH += ";$env:USERPROFILE"
macOS Installation
bash
# Homebrew
brew install jandedobbeleer/oh-my-posh/oh-my-posh
# Manual installation
curl -s https://ohmyposh.dev/install.sh | bash -s
# Add to PATH
export PATH=$PATH:/usr/local/bin
Linux Installation
bash
# Install script
curl -s https://ohmyposh.dev/install.sh | bash -s
# Manual download
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
chmod +x /usr/local/bin/oh-my-posh
# Package managers
# Arch Linux
yay -S oh-my-posh
# Ubuntu/Debian (via .deb package)
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64.deb
sudo dpkg -i posh-linux-amd64.deb
Font Installation
bash
# Install Nerd Fonts (required for icons)
oh-my-posh font install
# Install specific font
oh-my-posh font install meslo
# List available fonts
oh-my-posh font list
# Manual font installation
# Download from https://www.nerdfonts.com/
# Install CascadiaCode, FiraCode, or Meslo LG fonts
Shell Configuration
PowerShell Setup
powershell
# Add to PowerShell profile
# Check profile location
$PROFILE
# Create profile if it doesn't exist
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
# Add Oh My Posh initialization
Add-Content -Path $PROFILE -Value 'oh-my-posh init pwsh | Invoke-Expression'
# With custom theme
Add-Content -Path $PROFILE -Value 'oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression'
# Reload profile
. $PROFILE
Bash Setup
bash
# Add to ~/.bashrc
echo 'eval "$(oh-my-posh init bash)"' >> ~/.bashrc
# With custom theme
echo 'eval "$(oh-my-posh init bash --config ~/.poshthemes/jandedobbeleer.omp.json)"' >> ~/.bashrc
# Reload configuration
source ~/.bashrc
Zsh Setup
bash
# Add to ~/.zshrc
echo 'eval "$(oh-my-posh init zsh)"' >> ~/.zshrc
# With custom theme
echo 'eval "$(oh-my-posh init zsh --config ~/.poshthemes/jandedobbeleer.omp.json)"' >> ~/.zshrc
# Reload configuration
source ~/.zshrc
Fish Setup
bash
# Add to ~/.config/fish/config.fish
echo 'oh-my-posh init fish | source' >> ~/.config/fish/config.fish
# With custom theme
echo 'oh-my-posh init fish --config ~/.poshthemes/jandedobbeleer.omp.json | source' >> ~/.config/fish/config.fish
# Reload configuration
source ~/.config/fish/config.fish
Command Prompt (CMD) Setup
cmd
# Install Clink first
# Download from: https://chrisant996.github.io/clink/
# Create oh-my-posh.lua in Clink scripts directory
# %LOCALAPPDATA%\clink\oh-my-posh.lua
load(io.popen('oh-my-posh init cmd'):read("*a"))()
Theme Management
Built-in Themes
bash
# List all available themes
oh-my-posh get themes
# Preview themes
oh-my-posh get themes --list
# Set theme
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\agnoster.omp.json" | Invoke-Expression
# Popular themes
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json" | Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\powerlevel10k_rainbow.omp.json" | Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json" | Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\blue-owl.omp.json" | Invoke-Expression
Theme Locations
bash
# Windows theme location
$env:POSH_THEMES_PATH
# macOS/Linux theme location
$(oh-my-posh get themes-path)
# List theme files
# Windows
Get-ChildItem -Path "$env:POSH_THEMES_PATH" -Filter "*.omp.json"
# macOS/Linux
ls $(oh-my-posh get themes-path)/*.omp.json
Custom Theme Creation
json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"console_title_template": "{{ .Shell }} in {{ .Folder }}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#61AFEF",
"template": " \uF07C {{ .Path }} ",
"properties": {
"style": "folder"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"template": " {{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }} "
}
]
},
{
"type": "prompt",
"alignment": "right",
"segments": [
{
"type": "node",
"style": "plain",
"foreground": "#6CA35E",
"template": "\uF898 {{ .Full }} "
},
{
"type": "time",
"style": "plain",
"foreground": "#007ACC",
"template": "{{ .CurrentDate | date .Format }} "
}
]
},
{
"type": "prompt",
"alignment": "left",
"newline": true,
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#007ACC",
"template": "❯ "
}
]
}
]
}
Configuration Structure
Basic Configuration
json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"version": 2,
"final_space": true,
"console_title_template": "{{ .Shell }} in {{ .Folder }}",
"blocks": []
}
Block Configuration
json
{
"type": "prompt",
"alignment": "left",
"newline": false,
"segments": []
}
Segment Configuration
json
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#61AFEF",
"template": " \uF07C {{ .Path }} ",
"properties": {}
}
Core Segments
Path Segment
json
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#61AFEF",
"template": " \uF07C {{ .Path }} ",
"properties": {
"style": "folder",
"max_depth": 3,
"folder_separator_icon": " \uE0B1 ",
"home_icon": "~",
"folder_icon": "\uF07C",
"windows_registry_icon": "\uE0B1",
"mapped_locations": {
"C:\\temp": "\uF0E7",
"C:\\Users": "\uF007"
}
}
}
Git Segment
json
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}",
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
"{{ if gt .Behind 0 }}#B388FF{{ end }}"
],
"template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }} ",
"properties": {
"branch_max_length": 25,
"fetch_status": true,
"fetch_upstream_icon": true
}
}
Status Segment
json
{
"type": "status",
"style": "diamond",
"foreground": "#ffffff",
"background": "#00897b",
"background_templates": [
"{{ if gt .Code 0 }}#e91e63{{ end }}"
],
"leading_diamond": "<transparent,background>\uE0B0</>",
"trailing_diamond": "\uE0B4",
"template": " {{ if gt .Code 0 }}\uF00D{{ else }}\uF00C{{ end }} ",
"properties": {
"always_enabled": true
}
}
Time Segment
json
{
"type": "time",
"style": "plain",
"foreground": "#007ACC",
"template": "{{ .CurrentDate | date .Format }}",
"properties": {
"time_format": "15:04:05"
}
}
Language and Runtime Segments
Node.js Segment
json
{
"type": "node",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#6CA35E",
"template": " \uF898 {{ .Full }} ",
"properties": {
"fetch_version": true,
"missing_command_text": "",
"display_mode": "files",
"version_url_template": "https://nodejs.org/en/download/releases/",
"extensions": ["js", "ts"],
"folders": ["node_modules", ".nvmrc"],
"files": ["package.json", ".node-version", ".nvmrc"]
}
}
Python Segment
json
{
"type": "python",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#111111",
"background": "#FFDE57",
"template": " \uF81F {{ .Full }} ",
"properties": {
"display_mode": "files",
"fetch_virtual_env": false
}
}
Go Segment
json
{
"type": "go",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#111111",
"background": "#8ED1F7",
"template": " \uFCD1 {{ .Full }} ",
"properties": {
"fetch_version": true
}
}
Rust Segment
json
{
"type": "rust",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#99908a",
"template": " \uE7a8 {{ .Full }} ",
"properties": {
"fetch_version": true
}
}
Java Segment
json
{
"type": "java",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#4063D8",
"template": " \uF675 {{ .Full }} ",
"properties": {
"fetch_version": true
}
}
Docker Segment
json
{
"type": "docker",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#000000",
"background": "#0B59E7",
"template": " \uF308 {{ .Context }} ",
"properties": {
"display_mode": "files"
}
}
System Information Segments
OS Segment
json
{
"type": "os",
"style": "diamond",
"foreground": "#26C6DA",
"background": "#546E7A",
"leading_diamond": "\uE0B6",
"trailing_diamond": "<transparent,background>\uE0B0</>",
"template": " {{ if .WSL }}WSL at {{ end }}{{.Icon}} ",
"properties": {
"macos": "\uF179",
"ubuntu": "\uF31b",
"windows": "\uF17a"
}
}
Session Segment
json
{
"type": "session",
"style": "diamond",
"foreground": "#ffffff",
"background": "#c386f1",
"leading_diamond": "\uE0B6",
"trailing_diamond": "\uE0B0",
"template": " {{ .UserName }} ",
"properties": {
"display_host": false
}
}
Battery Segment
json
{
"type": "battery",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#f36943",
"background_templates": [
"{{if eq \"Charging\" .State.String}}#40c4ff{{end}}",
"{{if eq \"Discharging\" .State.String}}#ff5722{{end}}",
"{{if eq \"Full\" .State.String}}#4caf50{{end}}"
],
"template": " {{ if not .Error }}{{ .Icon }}{{ .Percentage }}{{ end }}{{ .Error }}\uF295 ",
"properties": {
"discharging_icon": "\uE231 ",
"charging_icon": "\uE234 ",
"charged_icon": "\uE22F "
}
}
Memory Segment
json
{
"type": "sysinfo",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#8f43f3",
"template": " \uF85A {{ round .PhysicalPercentUsed .Precision }}% ",
"properties": {
"precision": 2
}
}
Cloud and DevOps Segments
AWS Segment
json
{
"type": "aws",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#FFA400",
"template": " \uF270 {{.Profile}}{{if .Region}}@{{.Region}}{{end}} ",
"properties": {
"display_default": false
}
}
Azure Segment
json
{
"type": "az",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#000000",
"background": "#9ec3f0",
"template": " \uFD03 {{ .Name }} ",
"properties": {
"display_default": true
}
}
Kubernetes Segment
json
{
"type": "kubectl",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#000000",
"background": "#ebcc34",
"template": " \uFD31 {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} ",
"properties": {
"display_error": false
}
}
Terraform Segment
json
{
"type": "terraform",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#000000",
"background": "#ebcc34",
"template": " \uF1BB {{.WorkspaceName}} "
}
Advanced Features
Conditional Templates
json
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#193549",
"background": "#95ffa4",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#FF9248{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}#ff4500{{ end }}",
"{{ if gt .Ahead 0 }}#B388FF{{ end }}",
"{{ if gt .Behind 0 }}#B388FF{{ end }}"
],
"foreground_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}#E3F2FD{{ end }}"
],
"template": " {{ .UpstreamIcon }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uF046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0 }} \uF692 {{ .StashCount }}{{ end }} "
}
Custom Variables
json
{
"type": "text",
"style": "plain",
"foreground": "#E06C75",
"template": "{{ .Env.CUSTOM_VAR }} "
}
Cross-Platform Configuration
json
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "#ffffff",
"background": "#61AFEF",
"template": " {{ if .WSL }}\uF17a {{ end }}\uF07C {{ .Path }} ",
"properties": {
"style": "folder",
"mapped_locations": {
"C:\\temp": "\uF0E7",
"/tmp": "\uF0E7",
"~": "\uF015"
}
}
}
Multi-line Prompts
json
{
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "plain",
"foreground": "#61AFEF",
"template": "\uF07C {{ .Path }}"
}
]
},
{
"type": "prompt",
"alignment": "right",
"segments": [
{
"type": "time",
"style": "plain",
"foreground": "#007ACC",
"template": "{{ .CurrentDate | date .Format }}"
}
]
},
{
"type": "prompt",
"alignment": "left",
"newline": true,
"segments": [
{
"type": "text",
"style": "plain",
"foreground": "#007ACC",
"template": "❯ "
}
]
}
]
}
Customization and Styling
Color Schemes
json
{
"palette": {
"os-color": "#ACB0BE",
"closer-color": "#575656",
"pink": "#F25D94",
"lavender": "#LAVENDER",
"blue": "#06BCE4"
},
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "os",
"style": "diamond",
"foreground": "p:os-color",
"background": "p:closer-color",
"leading_diamond": "\uE0B6",
"trailing_diamond": "\uE0B0",
"template": " {{ .Icon }} "
}
]
}
]
}
Icons and Symbols
json
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"template": " {{ .UpstreamIcon }}{{ .HEAD }}{{ if .Working.Changed }} \uF044 {{ .Working.String }}{{ end }} ",
"properties": {
"branch_icon": "\uF126 ",
"commit_icon": "\uF417 ",
"fetch_status": true,
"fetch_upstream_icon": true,
"untracked_modes": {
"no": "\uF059",
"normal": "\uF059",
"all": "\uF059"
},
"status_formats": {
"added": "\uF457",
"copied": "\uF4A5",
"deleted": "\uF458",
"modified": "\uF459",
"renamed": "\uF45A",
"unmerged": "\uF426",
"untracked": "\uF059"
}
}
}
Powerline Symbols
json
{
"type": "path",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"inverse_powerline": false,
"foreground": "#ffffff",
"background": "#61AFEF",
"template": " \uF07C {{ .Path }} "
}
Diamond Style
json
{
"type": "os",
"style": "diamond",
"foreground": "#26C6DA",
"background": "#546E7A",
"leading_diamond": "\uE0B6",
"trailing_diamond": "\uE0B4",
"template": " {{ .Icon }} "
}
Performance and Optimization
Caching
json
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"template": " {{ .HEAD }} ",
"properties": {
"fetch_status": false,
"fetch_upstream_icon": false
}
}
Conditional Display
json
{
"type": "node",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"template": " \uF898 {{ .Full }} ",
"properties": {
"display_mode": "files",
"fetch_version": true
}
}
Timeout Configuration
json
{
"type": "kubectl",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"template": " \uFD31 {{.Context}} ",
"properties": {
"parse_kubeconfig": false,
"timeout": 2000
}
}
Command Line Usage
Theme Management
bash
# Get current theme
oh-my-posh get theme
# Set theme
oh-my-posh init pwsh --config "~/.mytheme.omp.json" | Invoke-Expression
# Export current theme
oh-my-posh config export --output ~/.mytheme.omp.json
# Validate theme
oh-my-posh config validate --config ~/.mytheme.omp.json
# Migrate theme from v2 to v3
oh-my-posh config migrate --config ~/.mytheme.omp.json
Debugging
bash
# Debug mode
oh-my-posh init pwsh --config ~/.mytheme.omp.json --debug | Invoke-Expression
# Print configuration
oh-my-posh config get --config ~/.mytheme.omp.json
# Test segment
oh-my-posh debug segment --config ~/.mytheme.omp.json --segment git
# Performance profiling
oh-my-posh init pwsh --config ~/.mytheme.omp.json --profile | Invoke-Expression
Cache Management
bash
# Clear cache
oh-my-posh cache clear
# Cache path
oh-my-posh cache path
# Cache statistics
oh-my-posh cache get --key git
Integration Examples
Windows Terminal Integration
json
{
"profiles": {
"defaults": {
"font": {
"face": "CascadiaCode Nerd Font"
}
},
"list": [
{
"name": "PowerShell",
"source": "Windows.Terminal.PowershellCore",
"startingDirectory": "%USERPROFILE%"
}
]
}
}
VS Code Integration
json
{
"terminal.integrated.fontFamily": "CascadiaCode Nerd Font",
"terminal.integrated.fontSize": 12,
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
}
}
}
Azure Cloud Shell
bash
# Install in Azure Cloud Shell
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d ~/bin
echo 'export PATH=$PATH:~/bin' >> ~/.bashrc
echo 'eval "$(oh-my-posh init bash)"' >> ~/.bashrc
Troubleshooting
Common Issues
powershell
# Font rendering issues
# Install Nerd Font and configure terminal
# PowerShell execution policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
# Module import issues
Import-Module oh-my-posh -Force
# Theme not loading
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression
# Performance issues
oh-my-posh init pwsh --config ~/.mytheme.omp.json --profile | Invoke-Expression
Debug Commands
bash
# Check installation
oh-my-posh --version
# Validate configuration
oh-my-posh config validate --config ~/.mytheme.omp.json
# Test specific segment
oh-my-posh debug segment --config ~/.mytheme.omp.json --segment path
# Environment information
oh-my-posh debug environment
Configuration Validation
bash
# Schema validation
oh-my-posh config validate --config ~/.mytheme.omp.json
# Export for sharing
oh-my-posh config export --output ~/.mytheme.omp.json
# Migrate old configuration
oh-my-posh config migrate --config ~/.old-theme.json
Oh My Posh provides a powerful, cross-platform solution for prompt customization that excels particularly in Windows environments while maintaining full compatibility with Unix-like systems. Its JSON-based configuration system, extensive theming capabilities, and strong Windows Terminal integration make it an excellent choice for developers working across multiple platforms. Whether you're using PowerShell on Windows, Bash on Linux, or any shell in between, Oh My Posh delivers consistent, beautiful, and informative prompts that enhance your command-line experience.