Skip to main content

Change your prompt

tip

If you have no idea which shell you're currently using, Oh My Posh has a utility switch that can tell that to you.

oh-my-posh get shell

Edit your PowerShell profile script, you can find its location under the $PROFILE variable in your preferred PowerShell version. For example, using notepad:

notepad $PROFILE
info

When the above command gives an error, make sure to create the profile first.

New-Item -Path $PROFILE -Type File -Force

In this scenario, it can also be that PowerShell blocks running local scripts. To solve that, set PowerShell to only require remote scripts to be signed using Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine, or sign the profile.

Add the following snippet as the last line to your PowerShell profile script:

oh-my-posh init pwsh | Invoke-Expression
Execution policy

In case the execution policy disables executing unsigned scripts on your system, you can fallback to evaluating the script instead. Use the --eval flag to do so:

oh-my-posh init pwsh --eval | Invoke-Expression

Be aware this will make initializing the shell slower.

Once added, reload your profile for the changes to take effect.

. $PROFILE

Package managers​

By default, the generated init script for most Oh My Posh installations uses the executable's absolute path. A package manager that removes the previous version during an upgrade can leave an existing shell pointing to a path that no longer exists.

Add --strict to resolve oh-my-posh through PATH instead:

eval "$(oh-my-posh init bash --strict)"

Use the equivalent init command for your shell. This keeps the prompt working when the version manager updates PATH to a new Oh My Posh installation.

Narrower terminal width​

Some hosts, such as an Emacs shell buffer or the Claude Code status line, report the full terminal width but only display part of it. Right-aligned segments then end up cut off at the edge.

Set POSH_MAX_COLUMNS_LESS to subtract a number of columns from the width the prompt is laid out at. It works with every shell. For example, to render the prompt 4 columns narrower than the terminal in Bash:

export POSH_MAX_COLUMNS_LESS=4
eval "$(oh-my-posh init bash)"

The --max-columns-less flag does the same for a single call. It is available on oh-my-posh print, oh-my-posh stream and the status line commands (oh-my-posh claude, oh-my-posh copilot and oh-my-posh antigravity) and takes precedence over the variable. It applies to the width given with --terminal-width or detected from the terminal. A value that is not smaller than the terminal width is ignored. For example, in the Claude Code settings.json:

{
"statusLine": {
"type": "command",
"command": "oh-my-posh claude --config ~/.config/ohmyposh/claude.toml --max-columns-less 10"
}
}