Direct naar hoofdinhoud

Gewenste Statusconfiguratie

Onofficiële Beta-vertaling

Deze pagina is vertaald door PageTurner AI (beta). Niet officieel goedgekeurd door het project. Een fout gevonden? Probleem melden →

Oh My Posh ondersteunt Gewenste Statusconfiguratie (DSC) voor declaratief configuratiebeheer, waardoor geautomatiseerde implementatie en consistente configuratie over meerdere systemen mogelijk wordt.

Concept

Oh My Posh DSC bouwt voort op de traditionele Oh My Posh-configuratieaanpak door automatisering en orchestratie- mogelijkheden toe te voegen. In plaats van handmatig je prompt te configureren, kun je de gewenste status declaratief definiëren en DSC zorgen dat je systeem aan die status voldoet.

DSC werkt met resources die verschillende aspecten van je Oh My Posh-installatie vertegenwoordigen:

  • Configuratie-resource: Beheert je Oh My Posh-configuratiebestanden

  • Shell-resource: Verwerkt shell-initialisatie en -integratie

  • Font-resource: Houdt geïnstalleerde Nerd Fonts bij

Deze resources kunnen standalone via de CLI worden gebruikt of geïntegreerd met orchestratietools zoals WinGet en Microsoft DSC voor geautomatiseerde implementaties.

Overzicht

DSC-ondersteuning in Oh My Posh biedt:

  • Declaratieve configuratie: Definieer de gewenste status van je Oh My Posh-installatie

  • Geautomatiseerde implementatie: Configureer Oh My Posh als onderdeel van systeemprovisioning-workflows

  • Shell-integratie: Configureer automatisch shell-initialisatie voor bash, zsh, fish, PowerShell en meer

  • Fontbeheer: Volg geïnstalleerde Nerd Fonts via DSC-status

  • Orchestratie-ondersteuning: Integratie met WinGet en Microsoft DSC-tools

DSC-functionaliteit is beschikbaar via de oh-my-posh CLI en kan standalone of met orchestratietools worden gebruikt.

DSC-resources

Oh My Posh biedt de volgende DSC-resources:

Configuratie-resource

Beheert Oh My Posh-configuratiebestanden.

Bewerkingen: get, set, export, schema

# Get current configuration state
oh-my-posh config dsc get

# Apply a configuration
oh-my-posh config dsc set --state '{"states":[{"source":"~/mytheme.omp.json","format":"json"}]}'

# Get configuration schema
oh-my-posh config dsc schema

Shell-resource

Beheert shell-initialisatie en -integratie.

Bewerkingen: get, set, export, schema

# Get current shell configurations
oh-my-posh init bash dsc get

# Configure shell initialization
oh-my-posh init bash dsc set --state '{"states":[{"name":"bash","command":"oh-my-posh init bash --config ~/mytheme.omp.json"}]}'

Font-resource

Houdt Nerd Fonts bij die via Oh My Posh zijn geïnstalleerd.

Bewerkingen: get, export, schema

# Get installed fonts
oh-my-posh font dsc get

# Get font schema
oh-my-posh font dsc schema

Direct CLI-gebruik

Je kunt de DSC-opdrachten direct vanaf de opdrachtregel gebruiken voor configuratiebeheer.

Configuraties beheren

Status ophalen

Haal de huidige configuratiestatus op:

oh-my-posh config dsc get

Voorbeelduitvoer:

{
"states": [
{
"format": "json",
"source": "~/mytheme.omp.json"
}
]
}

Status instellen

Pas een nieuwe configuratiestatus toe:

oh-my-posh config dsc set --state '{"states":[{"source":"~/mytheme.omp.json","format":"json"}]}'

Dit maakt het configuratiebestand op de opgegeven locatie aan of werkt het bij met het opgegeven formaat.

Schema

Verkrijg het JSON-schema voor de configuratie-resource:

oh-my-posh config dsc schema

Gebruik dit om de structuur en beschikbare opties voor configuratiestatussen te begrijpen.

Shell-integratie beheren

Bash

Configureer Oh My Posh-initialisatie voor bash:

# Get current state
oh-my-posh init bash dsc get

# Set initialization
oh-my-posh init bash dsc set --state '{"states":[{"name":"bash","command":"oh-my-posh init bash --config ~/mytheme.omp.json"}]}'

Dit werkt automatisch je .bashrc of .bash_profile bij met de Oh My Posh-initialisatieopdracht.

Zsh

Configureer Oh My Posh-initialisatie voor zsh:

# Get current state
oh-my-posh init zsh dsc get

# Set initialization
oh-my-posh init zsh dsc set --state '{"states":[{"name":"zsh","command":"oh-my-posh init zsh --config ~/mytheme.omp.json"}]}'

Dit werkt automatisch je .zshrc bij met de Oh My Posh-initialisatieopdracht.

PowerShell

Configureer Oh My Posh-initialisatie voor PowerShell:

# Get current state
oh-my-posh init pwsh dsc get

# Set initialization
oh-my-posh init pwsh dsc set --state '{"states":[{"name":"pwsh","command":"oh-my-posh init pwsh --config ~/mytheme.omp.json"}]}'

Dit werkt automatisch je PowerShell-profiel bij met de Oh My Posh-initialisatieopdracht.

Fish

Configureer Oh My Posh-initialisatie voor fish:

# Get current state
oh-my-posh init fish dsc get

# Set initialization
oh-my-posh init fish dsc set --state '{"states":[{"name":"fish","command":"oh-my-posh init fish --config ~/mytheme.omp.json"}]}'

Dit werkt automatisch je fish config.fish bij met het Oh My Posh-initialisatiecommando.

Orchestratie met WinGet

WinGet-configuratie stelt je in staat om Oh My Posh te installeren en configuratie in één declaratief bestand toe te passen.

Basis WinGet-configuratie

Maak een configuratiebestand om Oh My Posh te installeren en configureren:

oh-my-posh-setup.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/config/document.json
metadata:
winget:
processor: dscv3
resources:
- name: Install Oh My Posh
type: Microsoft.WinGet.DSC/WinGetPackage
properties:
id: JanDeDobbeleer.OhMyPosh
source: winget

Pas de configuratie toe:

winget configure oh-my-posh-setup.yaml

Volledige setup met configuratie en shell

Dit voorbeeld installeert Oh My Posh, voegt je configuratie toe en initialiseert PowerShell:

oh-my-posh-complete.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/config/document.json
metadata:
winget:
processor: dscv3
resources:
- name: Install Oh My Posh
type: Microsoft.WinGet.DSC/WinGetPackage
properties:
id: JanDeDobbeleer.OhMyPosh
source: winget

- name: Add Oh My Posh configuration
type: OhMyPosh/Config
properties:
states:
- source: ~/mytheme.omp.json
format: json

- name: Initialize PowerShell
type: OhMyPosh/Shell
properties:
states:
- name: pwsh
command: oh-my-posh init pwsh --config ~/mytheme.omp.json

Pas toe met:

winget configure oh-my-posh-complete.yaml

Multi-shell-configuratie

Initialiseer meerdere shells met verschillende configuraties:

oh-my-posh-multi-shell.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3/config/document.json
metadata:
winget:
processor: dscv3
resources:
- name: Install Oh My Posh
type: Microsoft.WinGet.DSC/WinGetPackage
properties:
id: JanDeDobbeleer.OhMyPosh
source: winget

- name: Add work configuration
type: OhMyPosh/Config
properties:
states:
- source: ~/work-theme.omp.json
format: json

- name: Add personal configuration
type: OhMyPosh/Config
properties:
states:
- source: ~/personal-theme.omp.json
format: json

- name: Initialize PowerShell with work configuration
type: OhMyPosh/Shell
properties:
states:
- name: pwsh
command: oh-my-posh init pwsh --config ~/work-theme.omp.json

- name: Initialize Bash with personal configuration
type: OhMyPosh/Shell
properties:
states:
- name: bash
command: oh-my-posh init bash --config ~/personal-theme.omp.json

Orchestratie met Microsoft DSC

Microsoft DSC (dsc) biedt platformoverschrijdende configuratiebeheermogelijkheden. Oh My Posh levert native DSC- resources die gebruikt kunnen worden in DSC-configuratiedocumenten.

Voorbeeld-DSC-configuratie

Maak een configuratiedocument voor Oh My Posh:

oh-my-posh-dsc.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Add Oh My Posh configuration
type: OhMyPosh/Config
properties:
states:
- source: ~/mytheme.omp.json
format: json

- name: Initialize PowerShell
type: OhMyPosh/Shell
properties:
states:
- name: pwsh
command: oh-my-posh init pwsh --config ~/mytheme.omp.json

Pas de configuratie toe met de dsc CLI:

dsc config set --document oh-my-posh-dsc.yaml

Volledige configuratie met meerdere shells

oh-my-posh-complete-dsc.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Add primary configuration
type: OhMyPosh/Config
properties:
states:
- source: ~/primary-theme.omp.json
format: json

- name: Add secondary configuration
type: OhMyPosh/Config
properties:
states:
- source: ~/secondary-theme.omp.json
format: yaml

- name: Initialize PowerShell
type: OhMyPosh/Shell
properties:
states:
- name: pwsh
command: oh-my-posh init pwsh --config ~/primary-theme.omp.json

- name: Initialize Bash
type: OhMyPosh/Shell
properties:
states:
- name: bash
command: oh-my-posh init bash --config ~/primary-theme.omp.json

- name: Initialize Zsh
type: OhMyPosh/Shell
properties:
states:
- name: zsh
command: oh-my-posh init zsh --config ~/secondary-theme.omp.json

Resourcetypen

Oh My Posh biedt de volgende DSC-resourcetypen:

OhMyPosh/Config

Beheert Oh My Posh-configuratiebestanden.

Eigenschappen:

  • states (array): Lijst van configuratiestaten
    • source (string): Pad naar het configuratiebestand
    • format (string): Formaat van het configuratiebestand (json, yaml, toml)

OhMyPosh/Shell

Beheert shell-initialisatie.

Eigenschappen:

  • states (array): Lijst van shellconfiguraties
    • name (string): Shellnaam (bash, zsh, pwsh, fish, etc.)
    • command (string): Oh My Posh-initialisatiecommando

OhMyPosh/Font

Houdt geïnstalleerde Nerd Fonts bij. Deze resource is alleen-lezen en wordt automatisch gevuld wanneer lettertypen via Oh My Posh worden geïnstalleerd.

Configuratiestatusbeheer

DSC-status wordt opgeslagen in de Oh My Posh-cache en blijft behouden tussen sessies. Dit maakt mogelijk:

  • Statusvolging: Oh My Posh onthoudt configuraties ingesteld via DSC

  • Idempotentie: Meerdere keren hetzelfde DSC-commando uitvoeren geeft hetzelfde resultaat

  • Statusvalidatie: Raadpleeg huidige status voor wijzigingen

Geavanceerd gebruik

Meerdere configuraties

Je kunt meerdere configuratiebestanden beheren:

oh-my-posh config dsc set --state '{
"states": [
{"source":"~/work.omp.json","format":"json"},
{"source":"~/personal.omp.json","format":"json"}
]
}'

Shell-specifieke initialisatie

Initialiseer meerdere shells met verschillende configuraties:

# Bash with one configuration
oh-my-posh init bash dsc set --state '{"states":[{"name":"bash","command":"oh-my-posh init bash --config ~/bash-theme.omp.json"}]}'

# PowerShell with another configuration
oh-my-posh init pwsh dsc set --state '{"states":[{"name":"pwsh","command":"oh-my-posh init pwsh --config ~/pwsh-theme.omp.json"}]}'

Ondersteunde shells

DSC-shellconfiguratie ondersteunt de volgende shells:

  • bash: Configureert .bashrc of .bash_profile

  • zsh: Configureert .zshrc

  • fish: Configureert ~/.config/fish/config.fish

  • pwsh: Configureert PowerShell-profiel ($PROFILE)

  • nu: Configureert ~/.config/nushell/config.nu

  • elvish: Configureert .elvish/rc.elv

  • xonsh: Configureert .xonshrc

De shell-integratie doet automatisch het volgende:

  • Maakt configuratiebestanden aan als ze niet bestaan

  • Werkt bestaande Oh My Posh initialisatiecommando's bij

  • Behoudt shellspecifieke opdrachtsyntax

  • Handhaaft correcte witruimte en opmaak

Zie ook