Customize
The standard initialization sets Oh My Posh' default theme. This configuration is embedded and thus kept up-to-date with Oh My Posh.
To set a new config/theme you need to change the --config
option of the oh-my-posh init <shell>
line in your profile
or .<shell>rc
script (see prompt) and point it to the location of a
predefined theme or custom configuration.
There are two possible values the --config
flag can handle:
- a path to a local configuration file
--config 'C:/Users/Posh/jandedobbeleer.omp.json'
- a URL pointing to a remote config
--config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/jandedobbeleer.omp.json'
Set the configuration
The example below use a local path to the jandedobbeleer theme, adjust the --config
value
to reflect your configuration file, local or remote.
- bash
- cmd
- elvish
- fish
- nu
- powershell
- tcsh
- xonsh
- zsh
Use the full path to the config file, not the relative path or ~
as a shorthand for $HOME
.
Adjust the Oh My Posh init line in ~/.bashrc
(could be ~/.profile
or ~/.bash_profile
depending
on your environment) by adding the --config
flag with the location of your configuration.
eval "$(oh-my-posh init bash --config ~/jandedobbeleer.omp.json)"
Once altered, reload your profile for the changes to take effect.
exec bash
Adjust the Oh My Posh init line in oh-my-posh.lua
by adding the --config
flag with the location
of your configuration.
load(io.popen('oh-my-posh init cmd --config C:/Users/Posh/jandedobbeleer.omp.json'):read("*a"))()
Use the full path to the config file, not the relative path. You can make use of forward slashes to avoid having to use double backslashes.
Once altered, restart cmd for the changes to take effect.
Adjust the Oh My Posh init line in ~/.elvish/rc.elv
by adding the --config
flag with the location
of your configuration.
eval (oh-my-posh init elvish --config ~/jandedobbeleer.omp.json)
Once added, reload your profile for the changes to take effect.
exec elvish
It is recommended to use the latest version of Fish. Versions below 3.1.2 have issues displaying the prompt.
Adjust the Oh My Posh init line in ~/.config/fish/config.fish
by adding the --config
flag with
the location of your configuration.
oh-my-posh init fish --config ~/jandedobbeleer.omp.json | source
Once altered, reload your config for the changes to take effect.
. ~/.config/fish/config.fish
Oh My Posh requires Nushell v0.93.0 or higher.
Adjust the Oh My Posh init line in the Nushell env file ($nu.env-path
) by adding the --config
flag
with the location of your configuration.
oh-my-posh init nu --config ~/jandedobbeleer.omp.json
This saves the initialization script to ~/.oh-my-posh.nu
.
Now, edit the Nushell config file ($nu.config-path
) and add the following line at the bottom:
source ~/.oh-my-posh.nu
If you want to save the initialization script elsewhere, you can change the first line to something like this:
oh-my-posh init nu --config ~/jandedobbeleer.omp.json --print | save /mylocation/myscript.nu --force
And change the source
line to:
source /mylocation/myscript.nu
Once altered, restart Nushell for the changes to take effect.
Adjust the Oh My Posh init line in your $PROFILE
by adding the --config
flag with the location
of your configuration.
oh-my-posh init pwsh --config ~/jandedobbeleer.omp.json | Invoke-Expression
Once altered, reload your profile for the changes to take effect.
. $PROFILE
When the above command gives an error, make sure to create the profile first and add the oh-my-posh init
above.
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 RemoteSigned
, or sign the profile.
Adjust the Oh My Posh init line in ~/.tcshrc
by adding the --config
flag with the location of your configuration.
eval "`oh-my-posh init tcsh --config ~/jandedobbeleer.omp.json`"
Note that the surrounding quotes are required. Once added, reload your profile for the changes to take effect.
exec tcsh
Adjust the Oh My Posh init line in ~/.xonshrc
by adding the --config
flag with the location of your configuration.
execx($(oh-my-posh init xonsh --config ~/jandedobbeleer.omp.json))
Once added, reload your profile for the changes to take effect.
exec xonsh
Adjust the Oh My Posh init line in ~/.zshrc
by adding the --config
flag with the location of your configuration.
eval "$(oh-my-posh init zsh --config ~/jandedobbeleer.omp.json)"
Once altered, reload your profile for the changes to take effect.
exec zsh
When using oh-my-posh in Windows and the WSL, know that you can share your theme with the WSL by pointing to a theme in your Windows user's home folder.
Inside the WSL, you can find your Windows user's home folder here: /mnt/c/Users/<WINDOWSUSERNAME>
.
Themes
The Windows and homebrew installers also bundle the predefined configurations (themes). You can use the following way to reference them directly. This will keep them up-to-date and compatible with future updates.
- windows
- homebrew
For example, to use the jandedobbeleer theme, alter the init line like this (powershell
):
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/jandedobbeleer.omp.json" | Invoke-Expression
When using homebrew, all themes are installed alongside Oh My Posh in $(brew --prefix oh-my-posh)/themes
.
To use any of the themes, use the following syntax (zsh
):
eval "$(oh-my-posh init zsh --config $(brew --prefix oh-my-posh)/themes/jandedobbeleer.omp.json)"
Custom configuration
Maybe there's a theme you like, but you don't fancy the colors. Or, maybe there's a segment you want to tweak/add, or replace some of the icons with a different one. Whatever the case, read through available options first, by starting with the configuration.
You can export the current theme (default, or set via --config
) to the format you like (json
, yaml
, or toml
)
which can be used to tweak and store as your own custom configuration.
oh-my-posh config export --output ~/.mytheme.omp.json
Be careful not to adjust the theme files in their original location as they're updated together with Oh My Posh which will remove your customizations. Always copy, or export them and save the new configuration outside of the Oh My Posh internal themes folder.
Read the docs
To fully understand how to customize a theme, read through the documentation in the configuration and segments sections. The configuration section covers the basic building blocks and concepts of Oh My Posh themes, while the segments section covers how to configure each available segment.