Hi team - thank you for sharing great config. I'm loving it!
I found that the current WindowsDeveloperConfig DSC setup can overwrite an existing custom oh-my-posh initialization line in my PowerShell profile.
First, I want to say I totally understand this project is intentionally opinionated, so using the default oh-my-posh setup is completely reasonable if that is the intended behavior. I’m opening this mostly because it was confusing to me at first that DSC was modifying only the oh-my-posh line in my PowerShell profile silently changing prompt, and I wanted to leave a note in case someone else runs into the same thing.
I also fully admit my suggested workaround may be a bit over-engineered and potentially inefficient: using a separate script-based DSC resource to detect an existing oh-my-posh line, even though there is already a dedicated OhMyPosh/Shell DSC implementation, is not ideal on paper. However, based on the current behavior on both sides, it seems like this may be the only practical way to avoid overwriting an existing custom oh-my-posh setup.
Current behavior
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.
Suggested change
Instead of using OhMyPosh/Shell directly here, please consider using a script-based DSC resource that:
- checks whether
$PROFILE already contains any non-comment oh-my-posh init line
- skips modification if one already exists
- only appends the default
oh-my-posh init pwsh | Invoke-Expression line when no existing oh-my-posh initialization is present
This would preserve existing user customization while still bootstrapping oh-my-posh for users who do not already have it configured.
Why I’m suggesting this on the WindowsDeveloperConfig side
The upstream oh-my-posh DSC resource currently rewrites the matched init line unless it already contains the exact canonical command string, so it does not preserve extra args like --config. I totally admit that writing separate script to check oh-my-posh init line is bit over-engineered and potentially inefficient.
Possible implementation direction
A Microsoft.DSC.Transitional/PowerShellScript resource could use:
testScript: return $true if $PROFILE already contains a non-comment oh-my-posh init line
setScript: create $PROFILE if missing and append the default line only if no such line exists
Expected behavior
If the profile already contains any valid oh-my-posh init command, DSC should treat that as compliant and avoid modifying it.
Hi team - thank you for sharing great config. I'm loving it!
I found that the current WindowsDeveloperConfig DSC setup can overwrite an existing custom
oh-my-poshinitialization line in my PowerShell profile.First, I want to say I totally understand this project is intentionally opinionated, so using the default
oh-my-poshsetup is completely reasonable if that is the intended behavior. I’m opening this mostly because it was confusing to me at first that DSC was modifying only theoh-my-poshline in my PowerShell profile silently changing prompt, and I wanted to leave a note in case someone else runs into the same thing.I also fully admit my suggested workaround may be a bit over-engineered and potentially inefficient: using a separate script-based DSC resource to detect an existing
oh-my-poshline, even though there is already a dedicatedOhMyPosh/ShellDSC implementation, is not ideal on paper. However, based on the current behavior on both sides, it seems like this may be the only practical way to avoid overwriting an existing customoh-my-poshsetup.Current behavior
In
windows-dev-config/dev-config.winget, the config uses:When DSC is applied, it updates the existing
oh-my-poshinit line in$PROFILEto the declared command.That means a custom line like:
gets rewritten to:
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 theoh-my-poshline is normalized and the custom theme/config is lost.Suggested change
Instead of using
OhMyPosh/Shelldirectly here, please consider using a script-based DSC resource that:$PROFILEalready contains any non-commentoh-my-posh initlineoh-my-posh init pwsh | Invoke-Expressionline when no existingoh-my-poshinitialization is presentThis would preserve existing user customization while still bootstrapping oh-my-posh for users who do not already have it configured.
Why I’m suggesting this on the WindowsDeveloperConfig side
The upstream
oh-my-poshDSC resource currently rewrites the matched init line unless it already contains the exact canonical command string, so it does not preserve extra args like--config. I totally admit that writing separate script to checkoh-my-posh initline is bit over-engineered and potentially inefficient.Possible implementation direction
A
Microsoft.DSC.Transitional/PowerShellScriptresource could use:testScript: return$trueif$PROFILEalready contains a non-commentoh-my-posh initlinesetScript: create$PROFILEif missing and append the default line only if no such line existsExpected behavior
If the profile already contains any valid
oh-my-posh initcommand, DSC should treat that as compliant and avoid modifying it.