Aller au contenu

Oh mon posh - Forme croisée Moteur rapide

Copier toutes les commandes Générer PDF

Oh My Posh est un moteur d'invite personnalisé pour tout shell qui a la capacité d'ajuster la chaîne d'invite avec une fonction ou une variable. Il est conçu pour être rapide, extensible et multiplateforme, avec une force particulière sur Windows PowerShell et Windows Terminal. Oh My Posh offre de beaux thèmes, des options de personnalisation étendues et une intégration transparente entre différents systèmes d'exploitation et coquilles.

Installation

Installation de Windows

PowerShell (Recommandé)

# Install via PowerShell Gallery
Install-Module oh-my-posh -Scope CurrentUser

# Install via Winget
winget install JanDeDobbeleer.OhMyPosh

# Install via Chocolatey
choco install oh-my-posh

# Install via Scoop
scoop install https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/oh-my-posh.json

Installation manuelle

# Download and install manually
Invoke-WebRequest -Uri "https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-windows-amd64.exe" -OutFile "$env:USERPROFILE\oh-my-posh.exe"

# Add to PATH
$env:PATH += ";$env:USERPROFILE"
```_

### installation macOS
```bash
# Homebrew
brew install jandedobbeleer/oh-my-posh/oh-my-posh

# Manual installation
curl -s https://ohmyposh.dev/install.sh|bash -s

# Add to PATH
export PATH=$PATH:/usr/local/bin
```_

### Installation Linux
```bash
# Install script
curl -s https://ohmyposh.dev/install.sh|bash -s

# Manual download
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64 -O /usr/local/bin/oh-my-posh
chmod +x /usr/local/bin/oh-my-posh

# Package managers
# Arch Linux
yay -S oh-my-posh

# Ubuntu/Debian (via .deb package)
wget https://github.com/JanDeDobbeleer/oh-my-posh/releases/latest/download/posh-linux-amd64.deb
sudo dpkg -i posh-linux-amd64.deb

Installation de la police

# Install Nerd Fonts (required for icons)
oh-my-posh font install

# Install specific font
oh-my-posh font install meslo

# List available fonts
oh-my-posh font list

# Manual font installation
# Download from https://www.nerdfonts.com/
# Install CascadiaCode, FiraCode, or Meslo LG fonts

Configuration de la coque

Configuration PowerShell

# Add to PowerShell profile
# Check profile location
$PROFILE

# Create profile if it doesn't exist
if (!(Test-Path -Path $PROFILE)) \\\\{
    New-Item -ItemType File -Path $PROFILE -Force
\\\\}

# Add Oh My Posh initialization
Add-Content -Path $PROFILE -Value 'oh-my-posh init pwsh|Invoke-Expression'

# With custom theme
Add-Content -Path $PROFILE -Value 'oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json"|Invoke-Expression'

# Reload profile
. $PROFILE

Configuration de la masse

# Add to ~/.bashrc
echo 'eval "$(oh-my-posh init bash)"' >> ~/.bashrc

# With custom theme
echo 'eval "$(oh-my-posh init bash --config ~/.poshthemes/jandedobbeleer.omp.json)"' >> ~/.bashrc

# Reload configuration
source ~/.bashrc

Configuration de Zsh

# Add to ~/.zshrc
echo 'eval "$(oh-my-posh init zsh)"' >> ~/.zshrc

# With custom theme
echo 'eval "$(oh-my-posh init zsh --config ~/.poshthemes/jandedobbeleer.omp.json)"' >> ~/.zshrc

# Reload configuration
source ~/.zshrc

Préparation du poisson

# Add to ~/.config/fish/config.fish
echo 'oh-my-posh init fish|source' >> ~/.config/fish/config.fish

# With custom theme
echo 'oh-my-posh init fish --config ~/.poshthemes/jandedobbeleer.omp.json|source' >> ~/.config/fish/config.fish

# Reload configuration
source ~/.config/fish/config.fish

Configuration de l'invite de commande (CMD)

# Install Clink first
# Download from: https://chrisant996.github.io/clink/

# Create oh-my-posh.lua in Clink scripts directory
# %LOCALAPPDATA%\clink\oh-my-posh.lua
load(io.popen('oh-my-posh init cmd'):read("*a"))()

Gestion des thèmes

Thèmes intégrés

# List all available themes
oh-my-posh get themes

# Preview themes
oh-my-posh get themes --list

# Set theme
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\agnoster.omp.json"|Invoke-Expression

# Popular themes
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json"|Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\paradox.omp.json"|Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\powerlevel10k_rainbow.omp.json"|Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\atomic.omp.json"|Invoke-Expression
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\blue-owl.omp.json"|Invoke-Expression

Lieux thématiques

# Windows theme location
$env:POSH_THEMES_PATH

# macOS/Linux theme location
$(oh-my-posh get themes-path)

# List theme files
# Windows
Get-ChildItem -Path "$env:POSH_THEMES_PATH" -Filter "*.omp.json"

# macOS/Linux
ls $(oh-my-posh get themes-path)/*.omp.json

Création de thème personnalisé

\\\\{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "version": 2,
  "final_space": true,
  "console_title_template": "\\\\{\\\\{ .Shell \\\\}\\\\} in \\\\{\\\\{ .Folder \\\\}\\\\}",
  "blocks": [
    \\\\{
      "type": "prompt",
      "alignment": "left",
      "segments": [
        \\\\{
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#61AFEF",
          "template": " \uF07C \\\\{\\\\{ .Path \\\\}\\\\} ",
          "properties": \\\\{
            "style": "folder"
          \\\\}
        \\\\},
        \\\\{
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#95ffa4",
          "template": " \\\\{\\\\{ .HEAD \\\\}\\\\}\\\\{\\\\{if .BranchStatus \\\\}\\\\} \\\\{\\\\{ .BranchStatus \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if .Working.Changed \\\\}\\\\} \uF044 \\\\{\\\\{ .Working.String \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if and (.Staging.Changed) (.Working.Changed) \\\\}\\\\}|\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if .Staging.Changed \\\\}\\\\} \uF046 \\\\{\\\\{ .Staging.String \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\} "
        \\\\}
      ]
    \\\\},
    \\\\{
      "type": "prompt",
      "alignment": "right",
      "segments": [
        \\\\{
          "type": "node",
          "style": "plain",
          "foreground": "#6CA35E",
          "template": "\uF898 \\\\{\\\\{ .Full \\\\}\\\\} "
        \\\\},
        \\\\{
          "type": "time",
          "style": "plain",
          "foreground": "#007ACC",
          "template": "\\\\{\\\\{ .CurrentDate|date .Format \\\\}\\\\} "
        \\\\}
      ]
    \\\\},
    \\\\{
      "type": "prompt",
      "alignment": "left",
      "newline": true,
      "segments": [
        \\\\{
          "type": "text",
          "style": "plain",
          "foreground": "#007ACC",
          "template": "❯ "
        \\\\}
      ]
    \\\\}
  ]
\\\\}

Structure de configuration

Configuration de base

\\\\{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "version": 2,
  "final_space": true,
  "console_title_template": "\\\\{\\\\{ .Shell \\\\}\\\\} in \\\\{\\\\{ .Folder \\\\}\\\\}",
  "blocks": []
\\\\}

Configuration du bloc

\\\\{
  "type": "prompt",
  "alignment": "left",
  "newline": false,
  "segments": []
\\\\}

Configuration du segment

\\\\{
  "type": "path",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#61AFEF",
  "template": " \uF07C \\\\{\\\\{ .Path \\\\}\\\\} ",
  "properties": \\\\{\\\\}
\\\\}

Segments principaux

Segment de trajectoire

\\\\{
  "type": "path",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#61AFEF",
  "template": " \uF07C \\\\{\\\\{ .Path \\\\}\\\\} ",
  "properties": \\\\{
    "style": "folder",
    "max_depth": 3,
    "folder_separator_icon": " \uE0B1 ",
    "home_icon": "~",
    "folder_icon": "\uF07C",
    "windows_registry_icon": "\uE0B1",
    "mapped_locations": \\\\{
      "C:\\temp": "\uF0E7",
      "C:\\Users": "\uF007"
    \\\\}
  \\\\}
\\\\}

Segment Git

\\\\{
  "type": "git",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#193549",
  "background": "#95ffa4",
  "background_templates": [
    "\\\\{\\\\{ if or (.Working.Changed) (.Staging.Changed) \\\\}\\\\}#FF9248\\\\{\\\\{ end \\\\}\\\\}",
    "\\\\{\\\\{ if and (gt .Ahead 0) (gt .Behind 0) \\\\}\\\\}#ff4500\\\\{\\\\{ end \\\\}\\\\}",
    "\\\\{\\\\{ if gt .Ahead 0 \\\\}\\\\}#B388FF\\\\{\\\\{ end \\\\}\\\\}",
    "\\\\{\\\\{ if gt .Behind 0 \\\\}\\\\}#B388FF\\\\{\\\\{ end \\\\}\\\\}"
  ],
  "template": " \\\\{\\\\{ .UpstreamIcon \\\\}\\\\}\\\\{\\\\{ .HEAD \\\\}\\\\}\\\\{\\\\{if .BranchStatus \\\\}\\\\} \\\\{\\\\{ .BranchStatus \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if .Working.Changed \\\\}\\\\} \uF044 \\\\{\\\\{ .Working.String \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if and (.Staging.Changed) (.Working.Changed) \\\\}\\\\}|\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if .Staging.Changed \\\\}\\\\} \uF046 \\\\{\\\\{ .Staging.String \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if gt .StashCount 0 \\\\}\\\\} \uF692 \\\\{\\\\{ .StashCount \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\} ",
  "properties": \\\\{
    "branch_max_length": 25,
    "fetch_status": true,
    "fetch_upstream_icon": true
  \\\\}
\\\\}

Segment d'état

\\\\{
  "type": "status",
  "style": "diamond",
  "foreground": "#ffffff",
  "background": "#00897b",
  "background_templates": [
    "\\\\{\\\\{ if gt .Code 0 \\\\}\\\\}#e91e63\\\\{\\\\{ end \\\\}\\\\}"
  ],
  "leading_diamond": "<transparent,background>\uE0B0</>",
  "trailing_diamond": "\uE0B4",
  "template": " \\\\{\\\\{ if gt .Code 0 \\\\}\\\\}\uF00D\\\\{\\\\{ else \\\\}\\\\}\uF00C\\\\{\\\\{ end \\\\}\\\\} ",
  "properties": \\\\{
    "always_enabled": true
  \\\\}
\\\\}

Segment temporel

\\\\{
  "type": "time",
  "style": "plain",
  "foreground": "#007ACC",
  "template": "\\\\{\\\\{ .CurrentDate|date .Format \\\\}\\\\}",
  "properties": \\\\{
    "time_format": "15:04:05"
  \\\\}
\\\\}

Segments linguistiques et temps d'exécution

Node.js Segment

\\\\{
  "type": "node",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#6CA35E",
  "template": " \uF898 \\\\{\\\\{ .Full \\\\}\\\\} ",
  "properties": \\\\{
    "fetch_version": true,
    "missing_command_text": "",
    "display_mode": "files",
    "version_url_template": "https://nodejs.org/en/download/releases/",
    "extensions": ["js", "ts"],
    "folders": ["node_modules", ".nvmrc"],
    "files": ["package.json", ".node-version", ".nvmrc"]
  \\\\}
\\\\}

Segment Python

\\\\{
  "type": "python",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#111111",
  "background": "#FFDE57",
  "template": " \uF81F \\\\{\\\\{ .Full \\\\}\\\\} ",
  "properties": \\\\{
    "display_mode": "files",
    "fetch_virtual_env": false
  \\\\}
\\\\}

Segment aller

\\\\{
  "type": "go",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#111111",
  "background": "#8ED1F7",
  "template": " \uFCD1 \\\\{\\\\{ .Full \\\\}\\\\} ",
  "properties": \\\\{
    "fetch_version": true
  \\\\}
\\\\}

Segment de rouille

\\\\{
  "type": "rust",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#193549",
  "background": "#99908a",
  "template": " \uE7a8 \\\\{\\\\{ .Full \\\\}\\\\} ",
  "properties": \\\\{
    "fetch_version": true
  \\\\}
\\\\}

Segment Java

\\\\{
  "type": "java",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#4063D8",
  "template": " \uF675 \\\\{\\\\{ .Full \\\\}\\\\} ",
  "properties": \\\\{
    "fetch_version": true
  \\\\}
\\\\}

Segment Docker

\\\\{
  "type": "docker",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#000000",
  "background": "#0B59E7",
  "template": " \uF308 \\\\{\\\\{ .Context \\\\}\\\\} ",
  "properties": \\\\{
    "display_mode": "files"
  \\\\}
\\\\}

Segments d'information du système

Segment OS

\\\\{
  "type": "os",
  "style": "diamond",
  "foreground": "#26C6DA",
  "background": "#546E7A",
  "leading_diamond": "\uE0B6",
  "trailing_diamond": "<transparent,background>\uE0B0</>",
  "template": " \\\\{\\\\{ if .WSL \\\\}\\\\}WSL at \\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{.Icon\\\\}\\\\} ",
  "properties": \\\\{
    "macos": "\uF179",
    "ubuntu": "\uF31b",
    "windows": "\uF17a"
  \\\\}
\\\\}

Débat de session

\\\\{
  "type": "session",
  "style": "diamond",
  "foreground": "#ffffff",
  "background": "#c386f1",
  "leading_diamond": "\uE0B6",
  "trailing_diamond": "\uE0B0",
  "template": " \\\\{\\\\{ .UserName \\\\}\\\\} ",
  "properties": \\\\{
    "display_host": false
  \\\\}
\\\\}

Segment de batterie

\\\\{
  "type": "battery",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#193549",
  "background": "#f36943",
  "background_templates": [
    "\\\\{\\\\{if eq \"Charging\" .State.String\\\\}\\\\}#40c4ff\\\\{\\\\{end\\\\}\\\\}",
    "\\\\{\\\\{if eq \"Discharging\" .State.String\\\\}\\\\}#ff5722\\\\{\\\\{end\\\\}\\\\}",
    "\\\\{\\\\{if eq \"Full\" .State.String\\\\}\\\\}#4caf50\\\\{\\\\{end\\\\}\\\\}"
  ],
  "template": " \\\\{\\\\{ if not .Error \\\\}\\\\}\\\\{\\\\{ .Icon \\\\}\\\\}\\\\{\\\\{ .Percentage \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ .Error \\\\}\\\\}\uF295 ",
  "properties": \\\\{
    "discharging_icon": "\uE231 ",
    "charging_icon": "\uE234 ",
    "charged_icon": "\uE22F "
  \\\\}
\\\\}

Segment de mémoire

\\\\{
  "type": "sysinfo",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#8f43f3",
  "template": " \uF85A \\\\{\\\\{ round .PhysicalPercentUsed .Precision \\\\}\\\\}% ",
  "properties": \\\\{
    "precision": 2
  \\\\}
\\\\}

Segments Cloud et DevOps

Segment AWS

\\\\{
  "type": "aws",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#FFA400",
  "template": " \uF270 \\\\{\\\\{.Profile\\\\}\\\\}\\\\{\\\\{if .Region\\\\}\\\\}@\\\\{\\\\{.Region\\\\}\\\\}\\\\{\\\\{end\\\\}\\\\} ",
  "properties": \\\\{
    "display_default": false
  \\\\}
\\\\}

Segment d'azur

\\\\{
  "type": "az",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#000000",
  "background": "#9ec3f0",
  "template": " \uFD03 \\\\{\\\\{ .Name \\\\}\\\\} ",
  "properties": \\\\{
    "display_default": true
  \\\\}
\\\\}

Secteur Kubernetes

\\\\{
  "type": "kubectl",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#000000",
  "background": "#ebcc34",
  "template": " \uFD31 \\\\{\\\\{.Context\\\\}\\\\}\\\\{\\\\{if .Namespace\\\\}\\\\} :: \\\\{\\\\{.Namespace\\\\}\\\\}\\\\{\\\\{end\\\\}\\\\} ",
  "properties": \\\\{
    "display_error": false
  \\\\}
\\\\}

Segment Terraform

\\\\{
  "type": "terraform",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#000000",
  "background": "#ebcc34",
  "template": " \uF1BB \\\\{\\\\{.WorkspaceName\\\\}\\\\} "
\\\\}

Caractéristiques avancées

Modèles conditionnels

\\\\{
  "type": "git",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#193549",
  "background": "#95ffa4",
  "background_templates": [
    "\\\\{\\\\{ if or (.Working.Changed) (.Staging.Changed) \\\\}\\\\}#FF9248\\\\{\\\\{ end \\\\}\\\\}",
    "\\\\{\\\\{ if and (gt .Ahead 0) (gt .Behind 0) \\\\}\\\\}#ff4500\\\\{\\\\{ end \\\\}\\\\}",
    "\\\\{\\\\{ if gt .Ahead 0 \\\\}\\\\}#B388FF\\\\{\\\\{ end \\\\}\\\\}",
    "\\\\{\\\\{ if gt .Behind 0 \\\\}\\\\}#B388FF\\\\{\\\\{ end \\\\}\\\\}"
  ],
  "foreground_templates": [
    "\\\\{\\\\{ if or (.Working.Changed) (.Staging.Changed) \\\\}\\\\}#E3F2FD\\\\{\\\\{ end \\\\}\\\\}"
  ],
  "template": " \\\\{\\\\{ .UpstreamIcon \\\\}\\\\}\\\\{\\\\{ .HEAD \\\\}\\\\}\\\\{\\\\{if .BranchStatus \\\\}\\\\} \\\\{\\\\{ .BranchStatus \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if .Working.Changed \\\\}\\\\} \uF044 \\\\{\\\\{ .Working.String \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if and (.Staging.Changed) (.Working.Changed) \\\\}\\\\}|\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if .Staging.Changed \\\\}\\\\} \uF046 \\\\{\\\\{ .Staging.String \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\}\\\\{\\\\{ if gt .StashCount 0 \\\\}\\\\} \uF692 \\\\{\\\\{ .StashCount \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\} "
\\\\}

Variables personnalisées

\\\\{
  "type": "text",
  "style": "plain",
  "foreground": "#E06C75",
  "template": "\\\\{\\\\{ .Env.CUSTOM_VAR \\\\}\\\\} "
\\\\}

Configuration multiplateforme

\\\\{
  "type": "path",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "foreground": "#ffffff",
  "background": "#61AFEF",
  "template": " \\\\{\\\\{ if .WSL \\\\}\\\\}\uF17a \\\\{\\\\{ end \\\\}\\\\}\uF07C \\\\{\\\\{ .Path \\\\}\\\\} ",
  "properties": \\\\{
    "style": "folder",
    "mapped_locations": \\\\{
      "C:\\temp": "\uF0E7",
      "/tmp": "\uF0E7",
      "~": "\uF015"
    \\\\}
  \\\\}
\\\\}

Demandes multilignes

\\\\{
  "blocks": [
    \\\\{
      "type": "prompt",
      "alignment": "left",
      "segments": [
        \\\\{
          "type": "path",
          "style": "plain",
          "foreground": "#61AFEF",
          "template": "\uF07C \\\\{\\\\{ .Path \\\\}\\\\}"
        \\\\}
      ]
    \\\\},
    \\\\{
      "type": "prompt",
      "alignment": "right",
      "segments": [
        \\\\{
          "type": "time",
          "style": "plain",
          "foreground": "#007ACC",
          "template": "\\\\{\\\\{ .CurrentDate|date .Format \\\\}\\\\}"
        \\\\}
      ]
    \\\\},
    \\\\{
      "type": "prompt",
      "alignment": "left",
      "newline": true,
      "segments": [
        \\\\{
          "type": "text",
          "style": "plain",
          "foreground": "#007ACC",
          "template": "❯ "
        \\\\}
      ]
    \\\\}
  ]
\\\\}

Personnalisation et styling

Schémas de couleurs

\\\\{
  "palette": \\\\{
    "os-color": "#ACB0BE",
    "closer-color": "#575656",
    "pink": "#F25D94",
    "lavender": "#LAVENDER",
    "blue": "#06BCE4"
  \\\\},
  "blocks": [
    \\\\{
      "type": "prompt",
      "alignment": "left",
      "segments": [
        \\\\{
          "type": "os",
          "style": "diamond",
          "foreground": "p:os-color",
          "background": "p:closer-color",
          "leading_diamond": "\uE0B6",
          "trailing_diamond": "\uE0B0",
          "template": " \\\\{\\\\{ .Icon \\\\}\\\\} "
        \\\\}
      ]
    \\\\}
  ]
\\\\}

Icônes et symboles

\\\\{
  "type": "git",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "template": " \\\\{\\\\{ .UpstreamIcon \\\\}\\\\}\\\\{\\\\{ .HEAD \\\\}\\\\}\\\\{\\\\{ if .Working.Changed \\\\}\\\\} \uF044 \\\\{\\\\{ .Working.String \\\\}\\\\}\\\\{\\\\{ end \\\\}\\\\} ",
  "properties": \\\\{
    "branch_icon": "\uF126 ",
    "commit_icon": "\uF417 ",
    "fetch_status": true,
    "fetch_upstream_icon": true,
    "untracked_modes": \\\\{
      "no": "\uF059",
      "normal": "\uF059",
      "all": "\uF059"
    \\\\},
    "status_formats": \\\\{
      "added": "\uF457",
      "copied": "\uF4A5",
      "deleted": "\uF458",
      "modified": "\uF459",
      "renamed": "\uF45A",
      "unmerged": "\uF426",
      "untracked": "\uF059"
    \\\\}
  \\\\}
\\\\}

Symboles des lignes électriques

\\\\{
  "type": "path",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "inverse_powerline": false,
  "foreground": "#ffffff",
  "background": "#61AFEF",
  "template": " \uF07C \\\\{\\\\{ .Path \\\\}\\\\} "
\\\\}

Style de diamant

\\\\{
  "type": "os",
  "style": "diamond",
  "foreground": "#26C6DA",
  "background": "#546E7A",
  "leading_diamond": "\uE0B6",
  "trailing_diamond": "\uE0B4",
  "template": " \\\\{\\\\{ .Icon \\\\}\\\\} "
\\\\}

Performance et optimisation

Cache

\\\\{
  "type": "git",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "template": " \\\\{\\\\{ .HEAD \\\\}\\\\} ",
  "properties": \\\\{
    "fetch_status": false,
    "fetch_upstream_icon": false
  \\\\}
\\\\}

Affichage conditionnel

\\\\{
  "type": "node",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "template": " \uF898 \\\\{\\\\{ .Full \\\\}\\\\} ",
  "properties": \\\\{
    "display_mode": "files",
    "fetch_version": true
  \\\\}
\\\\}

Configuration du délai

\\\\{
  "type": "kubectl",
  "style": "powerline",
  "powerline_symbol": "\uE0B0",
  "template": " \uFD31 \\\\{\\\\{.Context\\\\}\\\\} ",
  "properties": \\\\{
    "parse_kubeconfig": false,
    "timeout": 2000
  \\\\}
\\\\}

Utilisation de la ligne de commande

Gestion des thèmes

# Get current theme
oh-my-posh get theme

# Set theme
oh-my-posh init pwsh --config "~/.mytheme.omp.json"|Invoke-Expression

# Export current theme
oh-my-posh config export --output ~/.mytheme.omp.json

# Validate theme
oh-my-posh config validate --config ~/.mytheme.omp.json

# Migrate theme from v2 to v3
oh-my-posh config migrate --config ~/.mytheme.omp.json

Déboguement

# Debug mode
oh-my-posh init pwsh --config ~/.mytheme.omp.json --debug|Invoke-Expression

# Print configuration
oh-my-posh config get --config ~/.mytheme.omp.json

# Test segment
oh-my-posh debug segment --config ~/.mytheme.omp.json --segment git

# Performance profiling
oh-my-posh init pwsh --config ~/.mytheme.omp.json --profile|Invoke-Expression

Gestion des caches

# Clear cache
oh-my-posh cache clear

# Cache path
oh-my-posh cache path

# Cache statistics
oh-my-posh cache get --key git

Exemples d'intégration

Intégration du terminal Windows

\\\\{
  "profiles": \\\\{
    "defaults": \\\\{
      "font": \\\\{
        "face": "CascadiaCode Nerd Font"
      \\\\}
    \\\\},
    "list": [
      \\\\{
        "name": "PowerShell",
        "source": "Windows.Terminal.PowershellCore",
        "startingDirectory": "%USERPROFILE%"
      \\\\}
    ]
  \\\\}
\\\\}

Intégration du code VS

\\\\{
  "terminal.integrated.fontFamily": "CascadiaCode Nerd Font",
  "terminal.integrated.fontSize": 12,
  "terminal.integrated.profiles.windows": \\\\{
    "PowerShell": \\\\{
      "source": "PowerShell",
      "icon": "terminal-powershell"
    \\\\}
  \\\\}
\\\\}

Shell Nuage Azure

# Install in Azure Cloud Shell
curl -s https://ohmyposh.dev/install.sh|bash -s -- -d ~/bin
echo 'export PATH=$PATH:~/bin' >> ~/.bashrc
echo 'eval "$(oh-my-posh init bash)"' >> ~/.bashrc

Dépannage

Questions communes

# Font rendering issues
# Install Nerd Font and configure terminal

# PowerShell execution policy
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

# Module import issues
Import-Module oh-my-posh -Force

# Theme not loading
oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH\jandedobbeleer.omp.json"|Invoke-Expression

# Performance issues
oh-my-posh init pwsh --config ~/.mytheme.omp.json --profile|Invoke-Expression

Déboguer les commandes

# Check installation
oh-my-posh --version

# Validate configuration
oh-my-posh config validate --config ~/.mytheme.omp.json

# Test specific segment
oh-my-posh debug segment --config ~/.mytheme.omp.json --segment path

# Environment information
oh-my-posh debug environment

Validation de configuration

# Schema validation
oh-my-posh config validate --config ~/.mytheme.omp.json

# Export for sharing
oh-my-posh config export --output ~/.mytheme.omp.json

# Migrate old configuration
oh-my-posh config migrate --config ~/.old-theme.json

Oh My Posh fournit une solution multiplateforme puissante pour une personnalisation rapide qui excelle particulièrement dans les environnements Windows tout en maintenant une compatibilité complète avec les systèmes Unix. Son système de configuration basé sur JSON, ses nombreuses capacités de thème et sa forte intégration dans Windows Terminal en font un excellent choix pour les développeurs travaillant sur plusieurs plateformes. Que vous utilisiez PowerShell sous Windows, Bash sous Linux ou n'importe quel shell entre les deux, Oh My Posh fournit des instructions cohérentes, belles et informatives qui améliorent votre expérience en ligne de commande.