Skip to content

fix(dev-config): Use skipExistingInit to prevent overwriting existing oh-my-posh config#87

Open
shunkino wants to merge 1 commit into
microsoft:mainfrom
shunkino:ohmyposh-skip-existing-init
Open

fix(dev-config): Use skipExistingInit to prevent overwriting existing oh-my-posh config#87
shunkino wants to merge 1 commit into
microsoft:mainfrom
shunkino:ohmyposh-skip-existing-init

Conversation

@shunkino

@shunkino shunkino commented Jul 1, 2026

Copy link
Copy Markdown

Fixes #53

Issue

In windows-dev-config/dev-config.winget, the config uses:

- type: OhMyPosh/Shell
  name: ohMyPoshProfileSet
  dependsOn:
    - OhMyPosh
  properties:
    states:
      - name: pwsh
        command: oh-my-posh init pwsh

When DSC is applied, it updates the existing oh-my-posh init line in $PROFILE to the declared command.

That means a custom line like:

oh-my-posh init pwsh --config "$HOME\.config\oh-my-posh\M365Princess.omp.json" | Invoke-Expression

gets rewritten to:

oh-my-posh init pwsh | Invoke-Expression

Why this is a problem

Many users customize their prompt via --config, and this is valid/manual user configuration. The rest of the profile remains untouched, but the oh-my-posh line is normalized and the custom theme/config is lost.

Fix

Thanks to the upstream improvement, oh-my-posh DSC module now have a feature to skip the update when there's existing configuration.

With this, we can simply fix the issue like this:

- type: OhMyPosh/Shell
  name: ohMyPoshProfileSet
  dependsOn:
    - OhMyPosh
  properties:
    states:
      - name: pwsh
        command: oh-my-posh init pwsh
        skipExistingInit: true

@shunkino shunkino force-pushed the ohmyposh-skip-existing-init branch from 6a61b02 to 23ac5ac Compare July 1, 2026 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DSC config overwrites existing custom oh-my-posh PowerShell profile line

1 participant