Aanpassen
Deze pagina is vertaald door PageTurner AI (beta). Niet officieel goedgekeurd door het project. Een fout gevonden? Probleem melden →
De standaard initialisatie gebruikt Oh My Posh' standaard ingebouwde thema.
Om een nieuwe configuratie of thema in te stellen, moet je de --config optie in de oh-my-posh init <shell> regel
aanpassen in je profile of .<shell>rc script (zie prompt).
De --config vlag accepteert drie soorten waarden:
-
een pad naar een lokaal configuratiebestand
--config 'C:/Users/Posh/myconfig.omp.json' -
een themanaam zonder extensie
--config 'jandedobbeleer' -
een URL naar een externe configuratie
--config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/jandedobbeleer.omp.json'
Het gebruik van een themanaam (zoals jandedobbeleer) of een externe URL vereist een actieve internetverbinding
en downloadt de configuratie bij het starten van de shell. Caching is ingeschakeld, maar voor betere prestaties
wordt een lokaal configuratiebestand aanbevolen.
Configuratie instellen
Het onderstaande voorbeeld gebruikt een lokaal pad naar het jandedobbeleer thema. Pas de --config waarde
aan om je eigen configuratiebestand te gebruiken, lokaal of extern.
- bash
- cmd
- elvish
- fish
- nu
- powershell
- 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 4.1.0 have issues and do not support [transient 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.104.0 or higher.
Adjust the Oh My Posh init line in the Nushell config file ($nu.config-path) by adding the --config flag
with the location of your configuration.
oh-my-posh init nu --config ~/jandedobbeleer.omp.json
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][sign].
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
Bij gebruik van Oh My Posh in Windows en WSL kun je je thema delen met WSL door te verwijzen naar een thema in je Windows gebruikersmap.
In WSL vind je de Windows gebruikersmap hier: /mnt/c/Users/<WINDOWSUSERNAME>.
Aangepaste configuratie
Wellicht vind je een thema mooi, maar bevalt het kleurenschema niet. Of misschien wil je een segment aanpassen/toevoegen, of iconen vervangen. Bekijk eerst de beschikbare opties via de configuratie.
Je kunt het huidige thema (standaard of ingesteld via --config) exporteren naar een gewenst formaat (json, yaml of toml)
om aan te passen en op te slaan als eigen configuratie.
oh-my-posh config export --config jandedobbeleer --output ~/.mytheme.omp.json
Live herladen
Standaard wordt de configuratie gecached voor betere prestaties. Na wijzigingen in je configuratiebestand kun je deze direct in je prompt zien zonder je shell te herstarten met deze opdracht:
oh-my-posh enable reload
Schakel live herladen uit met:
oh-my-posh disable reload
Wijzigingen vooraf bekijken
Bekijk je aanpassingen vooraf door elke geconfigureerde prompt te renderen met:
oh-my-posh print preview
Gebruik de --force vlag om alle segmenten te renderen, ongeacht de huidige context.
oh-my-posh print preview --force
Lees de documentatie
Lees de configuratie- en segmentensecties om thema's volledig te begrijpen. De configuratie behandelt de basisbouwstenen en concepten, terwijl de segmentensectie de configuratie van elk beschikbaar segment uitlegt.