Personnaliser
Cette page a été traduite par PageTurner AI (bêta). Non approuvée officiellement par le projet. Vous avez trouvé une erreur ? Signaler un problème →
L'initialisation standard configure le thème intégré par défaut d'Oh My Posh.
Pour définir une nouvelle configuration ou thème, modifiez l'option --config dans la commande oh-my-posh init <shell>
de votre script profile ou .<shell>rc (voir l'invite).
Voici les trois types de valeurs acceptées par le drapeau --config :
-
un chemin vers un fichier de configuration local
--config 'C:/Users/Posh/myconfig.omp.json' -
une référence à un thème, sans extension
--config 'jandedobbeleer' -
une URL pointant vers une configuration distante
--config 'https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/jandedobbeleer.omp.json'
L'utilisation d'un nom de thème (comme jandedobbeleer) ou d'une URL distante nécessite une connexion Internet active
et téléchargera la configuration au démarrage du shell. Un cache est mis en place, mais pour de meilleures performances,
il est recommandé d'utiliser un fichier de configuration local.
Définir la configuration
L'exemple ci-dessous utilise un chemin local vers le thème jandedobbeleer. Ajustez la valeur de --config
pour correspondre à votre fichier de configuration, local ou distant.
- 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
Sous Windows avec WSL, vous pouvez partager votre thème avec le WSL en pointant vers un thème dans votre dossier utilisateur Windows.
Dans le WSL, ce dossier se trouve ici : /mnt/c/Users/<WINDOWSUSERNAME>.
Configuration personnalisée
Vous aimez un thème mais pas ses couleurs ? Vous souhaitez modifier un segment, en ajouter un, ou changer certaines icônes ? Dans tous les cas, consultez d'abord les options disponibles en commençant par la configuration.
Vous pouvez exporter le thème actuel (par défaut ou défini via --config) dans votre format préféré (json, yaml ou toml)
pour le personnaliser et l'enregistrer comme configuration personnelle.
oh-my-posh config export --config jandedobbeleer --output ~/.mytheme.omp.json
Rechargement dynamique
Par défaut, la configuration est mise en cache pour des performances optimales. Pour voir les modifications d'un fichier de configuration sans redémarrer le shell, utilisez cette commande pour activer le rechargement dynamique.
oh-my-posh enable reload
Désactivez le rechargement dynamique avec :
oh-my-posh disable reload
Prévisualisation des modifications
Pour prévisualiser vos changements, utilisez cette commande pour afficher chaque invite configurée.
oh-my-posh print preview
Ajoutez le drapeau --force pour afficher tous les segments, quel que soit le contexte actuel.
oh-my-posh print preview --force
Consulter la documentation
Pour maîtriser la personnalisation des thèmes, consultez les sections configuration et segments. La configuration couvre les concepts fondamentaux des thèmes Oh My Posh, tandis que la section segments explique comment configurer chaque segment disponible.