Skip to content

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

Merged
AmirMS (AmelBawa-msft) merged 1 commit into
microsoft:mainfrom
shunkino:ohmyposh-skip-existing-init
Jul 22, 2026
Merged

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

Conversation

@shunkino

Copy link
Copy Markdown
Contributor

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
shunkin (shunkino) force-pushed the ohmyposh-skip-existing-init branch from 6a61b02 to 23ac5ac Compare July 1, 2026 02:45
@shunkino
shunkin (shunkino) force-pushed the ohmyposh-skip-existing-init branch from 1ea3eb5 to 98e275e Compare July 13, 2026 22:50
@AmelBawa-msft
AmirMS (AmelBawa-msft) merged commit 0a17ed5 into microsoft:main Jul 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants