🎨 Oh My Posh Install & Quick Reference

Oh My Posh Install Guide and Cheat Sheet / survival guide

Video: Oh My Posh (Command Line Tips video)
Prefer to watch? This short video runs this page's main commands on a real Ubuntu 24.04 machine, with on-screen captions and no voiceover. Click to play, or watch it on YouTube.
oh-my-posh init <shell> --config <file>
eval "$(oh-my-posh init bash --config ~/.config/ohmyposh/config.json)"

Oh My Posh is a fast, cross-platform prompt engine. It replaces the plain "user@host:~$" with a
themed, information-rich prompt: current folder, git branch and status, language versions, command
duration, exit code, cloud and Kubernetes context, and more. It works in bash, zsh, fish, PowerShell,
nu, cmd and others, on Linux, macOS and Windows (including WSL). It is a single program plus a config
file, so your prompt can look the same everywhere.

What you need

1. The oh-my-posh program            (Install, below)
2. A Nerd Font in your terminal      (icons and glyphs come from the font. Without one you see boxes or ?)
3. One line in your shell's startup file (Enable it, below)
4. A theme or config file            (Themes, below)

Step 1: Install oh-my-posh

Linux (any distribution)

curl -s https://ohmyposh.dev/install.sh | bash -s
By default it installs the program into a user or system bin folder and prints the location.
To choose the folder, and to avoid needing sudo:
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d ~/.local/bin
Read the script first if you prefer: curl -s https://ohmyposh.dev/install.sh | less
Make sure the folder is on your PATH. Add this to ~/.bashrc if it is not:
export PATH="$HOME/.local/bin:$PATH"

macOS and Linux with Homebrew
brew install jandedobbeleer/oh-my-posh/oh-my-posh

Windows

winget install JanDeDobbeleer.OhMyPosh -s winget
(Then close and reopen the terminal so the new PATH is picked up.)
Also available: scoop, Chocolatey, the Microsoft Store, and Arch (AUR) packages. See ohmyposh.dev/docs/installation.

Check it works

oh-my-posh version
which oh-my-posh                            # Linux and macOS (Windows: Get-Command oh-my-posh)
If "command not found": the install folder is not on your PATH. Fix the PATH and open a new terminal.

Step 2: Install a Nerd Font

oh-my-posh font install                     # pick from a list interactively
oh-my-posh font install meslo               # install Meslo Nerd Font directly
Or download one from nerdfonts.com (good choices: MesloLGM Nerd Font, FiraCode Nerd Font, JetBrainsMono Nerd Font),
unzip it, and install the .ttf files (double-click on Windows and macOS, or copy to ~/.local/share/fonts then run fc-cache -fv on Linux).
Then set the font in your terminal (the font must be selected in the TERMINAL app, not the shell):
Windows Terminal      Settings > Profiles > Defaults > Appearance > Font face > "MesloLGM Nerd Font"
GNOME Terminal        Preferences > your profile > Text > Custom font
macOS Terminal        Settings > Profiles > Text > Font > Change
iTerm2                Settings > Profiles > Text > Font
VS Code terminal      "terminal.integrated.fontFamily": "MesloLGM Nerd Font"    in settings.json
Over SSH, the font is chosen by the terminal on YOUR computer, not by the remote server.
On a remote server, install oh-my-posh there too (the prompt is drawn on the server), but the font stays on your machine.

Step 3: Enable it in your shell

Add ONE line to your shell's startup file, then open a new terminal (or source the file).

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
PowerShell  $PROFILE   (open it with: notepad $PROFILE, or code $PROFILE)
oh-my-posh init pwsh | Invoke-Expression
nushell     see ohmyposh.dev/docs/installation/prompt
cmd         use Clink: see ohmyposh.dev/docs/installation/prompt

With a chosen theme or config file (use --config):
eval "$(oh-my-posh init bash --config ~/.config/ohmyposh/config.json)"
eval "$(oh-my-posh init bash --config ~/.cache/oh-my-posh/themes/jandedobbeleer.omp.json)"
oh-my-posh init fish --config ~/.config/ohmyposh/config.json | source
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json" | Invoke-Expression
A URL also works: --config https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/atomic.omp.json
Apply changes without restarting:
source ~/.bashrc          (bash)      source ~/.zshrc          (zsh)      exec fish            (fish)      . $PROFILE         (PowerShell)
To check which shell it detects: oh-my-posh get shell

Step 4: Themes

Oh My Posh ships with over 100 ready-made themes. Where they live depends on how you installed it:
Linux (install script)  ~/.cache/oh-my-posh/themes/          (the installer downloads them)
Homebrew                $(brew --prefix oh-my-posh)/themes
Windows                 %POSH_THEMES_PATH%   ($env:POSH_THEMES_PATH in PowerShell)
Preview them online at ohmyposh.dev/docs/themes, or list local files:
ls ~/.cache/oh-my-posh/themes/
Popular themes: jandedobbeleer, atomic, agnoster, powerlevel10k_rainbow, catppuccin_mocha, paradox, pure, minimal, tokyo, night-owl, robbyrussell
Try one for this session only:
eval "$(oh-my-posh init bash --config ~/.cache/oh-my-posh/themes/atomic.omp.json)"
Make a personal copy that you can edit (recommended):
mkdir -p ~/.config/ohmyposh
cp ~/.cache/oh-my-posh/themes/atomic.omp.json ~/.config/ohmyposh/config.json
or: oh-my-posh config export --output ~/.config/ohmyposh/config.json
Then point your startup line at ~/.config/ohmyposh/config.json.
Keep the file in git or your dotfiles repo, and your prompt follows you to every machine.

Step 5: Customize the config

Config files can be JSON, YAML or TOML. A minimal JSON example (config.json):
{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "version": 3,
  "final_space": true,
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "",
          "foreground": "#ffffff",
          "background": "#0077c2",
          "template": " {{ .Path }} ",
          "properties": { "style": "folder" }
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "",
          "foreground": "#193549",
          "background": "#95ffa4",
          "template": " {{ .HEAD }}{{ if .Working.Changed }} {{ end }} ",
          "properties": { "fetch_status": true }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "left",
      "newline": true,
      "segments": [
        { "type": "text", "style": "plain", "foreground": "#ffffff", "template": "❯" }
      ]
    }
  ]
}
The "$schema" line gives editors (such as VS Code) autocomplete and error checking in the config.
Config format versions change over time. To upgrade an old file: oh-my-posh config migrate --config FILE --write

Core ideas

Block       A row of the prompt (left, right, or a whole new line). Types: prompt, rprompt, and more
Segment     One piece of information inside a block (path, git, time, ...)
Style       plain, powerline, diamond, or accordion: how the segment looks and joins its neighbors
Template    Go template text with values: " {{ .UserName }}@{{ .HostName }} "
Colors      Hex (#ff8800), named colors, or palette keys. Use "p:name" to reuse a palette color
Properties  Options for one segment type (for example, git fetch_status)
Newline     "newline": true starts a new line, so the command is typed on its own line
session          User and host name                     path             Current folder
git              Branch, ahead/behind, changed files    time             Clock
executiontime    How long the last command took         status           Exit code of the last command
os               Operating system icon                  shell            Which shell
root             Shows when you are root                battery          Battery level
node / python / go / rust / java / dotnet / php   Language version when the folder uses it
docker / kubectl / terraform / az / aws / gcp     Container, cluster and cloud context
text             Any fixed text or an icon              command          Output of any command you choose
All segments and their options: ohmyposh.dev/docs/segments/

Useful template values

{{ .UserName }}  {{ .HostName }}  {{ .Shell }}  {{ .Root }}  {{ .PWD }}  {{ .Folder }}  {{ .Path }}
{{ .Code }}     the exit code of the last command       {{ .Env.VARIABLE }}   an environment variable
{{ if eq .Code 0 }} ok {{ else }} failed {{ end }}      Conditions and loops work too
{{ .FormattedMs }}   command duration (executiontime segment)

Enable, disable and useful commands

oh-my-posh init bash --config FILE          Print the startup script for a shell
oh-my-posh print primary --config FILE      Draw the prompt once (good for testing a config)
oh-my-posh debug                            Show the config in use, the shell, fonts and how long each segment takes
oh-my-posh config export --output FILE      Save the current config to a file
oh-my-posh config migrate --config FILE --write   Update an old config to the newest format
oh-my-posh config edit                      Open the config in your editor (if supported by your version)
oh-my-posh enable notice / disable notice   Turn upgrade notices on or off
oh-my-posh cache clear                      Clear cached data (fixes stale git, version or cloud info)
oh-my-posh upgrade                          Update to the latest release (where supported)
oh-my-posh version
oh-my-posh --help    oh-my-posh <command> --help

Update and uninstall

Linux script      Run the install script again to update
Homebrew          brew upgrade oh-my-posh          brew uninstall oh-my-posh
Windows           winget upgrade JanDeDobbeleer.OhMyPosh       winget uninstall JanDeDobbeleer.OhMyPosh
To stop using it: delete the eval / init line from your startup file. Your old prompt returns in a new terminal.
The program, themes and cache can be removed: rm ~/.local/bin/oh-my-posh; rm -r ~/.cache/oh-my-posh

Keep it fast

A prompt runs before every command, so slow segments make the whole terminal feel sluggish.
- Run: oh-my-posh debug     It lists how many milliseconds each segment takes
- Remove or simplify slow segments (cloud and Kubernetes lookups, git status in huge repositories)
- Show language and cloud segments only in the folders that need them (they hide themselves when unused)
- Set git properties like "fetch_status": false, "fetch_upstream_icon": false if git is slow
- Use a right-side block ("alignment": "right") for information you look at rarely
- Prefer the built-in segments over "command" segments that start an external program
Aim for a prompt that renders in well under 100 ms.

Practical setups

# Quick trial of a theme without changing any files
eval "$(oh-my-posh init bash --config ~/.cache/oh-my-posh/themes/catppuccin_mocha.omp.json)"

# Same prompt on every machine (dotfiles)
mkdir -p ~/dotfiles/ohmyposh && cp ~/.config/ohmyposh/config.json ~/dotfiles/ohmyposh/
ln -sf ~/dotfiles/ohmyposh/config.json ~/.config/ohmyposh/config.json

# Different config for a server (simple) vs your laptop (fancy)
if [ -n "$SSH_CONNECTION" ]; then
  eval "$(oh-my-posh init bash --config ~/.config/ohmyposh/server.json)"
else
  eval "$(oh-my-posh init bash --config ~/.config/ohmyposh/desktop.json)"
fi

# Skip Oh My Posh in dumb terminals and non-interactive shells
[[ $- == *i* && $TERM != dumb ]] && eval "$(oh-my-posh init bash --config ~/.config/ohmyposh/config.json)"

# Install a prompt on a new Linux server in three lines
curl -s https://ohmyposh.dev/install.sh | bash -s -- -d ~/.local/bin
mkdir -p ~/.config/ohmyposh && curl -sL -o ~/.config/ohmyposh/config.json https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/atomic.omp.json
echo 'eval "$(oh-my-posh init bash --config ~/.config/ohmyposh/config.json)"' >> ~/.bashrc

# WSL: use the same config as Windows
eval "$(oh-my-posh init bash --config /mnt/c/Users/YOU/.config/ohmyposh/config.json)"

Common problems

Boxes, question marks or missing icons     The terminal is not using a Nerd Font. Set it in the terminal's font settings
Prompt shows raw text like           Use a JSON config with proper escapes, and a Nerd Font
"oh-my-posh: command not found"            The install folder is not on PATH. Add it to your startup file
Nothing changes after editing the config   Open a new terminal, or source the startup file. Check the --config path
Prompt is very slow                        oh-my-posh debug, then remove the slow segments. Try oh-my-posh cache clear
Wrong colors                               The terminal may not support true color: set COLORTERM=truecolor, or use named colors
Segments overlap or lines wrap oddly       Font width issues. Use the Mono variant of the Nerd Font (for example "MesloLGM Nerd Font Mono")
Works locally but not over SSH             Install oh-my-posh on the server as well. The font still comes from your local terminal
Config warnings or errors                  oh-my-posh config migrate --config FILE --write, and check the $schema in an editor
Git segment blank                          Not in a git repository, or git is not installed / not on PATH
VS Code terminal shows odd glyphs          Set terminal.integrated.fontFamily to your Nerd Font
Windows PowerShell 5 problems              Use PowerShell 7 (pwsh) if you can, and keep the profile script simple

Tips

    Start with a ready-made theme, copy it to ~/.config/ohmyposh/config.json, and change small things one at a time.

    Install a Nerd Font first. Almost every "my prompt looks broken" problem is a missing font.

    Put the config file and the init line in your dotfiles repository so every machine looks the same.

    Keep the prompt fast. Use oh-my-posh debug to find slow segments, and hide anything you do not look at.

    Use the "$schema" line and an editor with JSON support to get autocomplete for every option.

    Make the prompt useful, not just pretty: exit code, git status, and command duration save real time.

    Keep a plain fallback (for example, a simple config for servers and recovery shells) in case a prompt fails.

    Oh My Posh only changes the prompt. It does not replace your shell, so it works alongside bash, zsh, fish and PowerShell.

    Check ohmyposh.dev for the newest install instructions and config format. Options and versions change between releases.