Title: DSC config overwrites existing custom oh-my-posh PowerShell profile line · Issue #53 · microsoft/WindowsDeveloperConfig · GitHub
Open Graph Title: DSC config overwrites existing custom oh-my-posh PowerShell profile line · Issue #53 · microsoft/WindowsDeveloperConfig
X Title: DSC config overwrites existing custom oh-my-posh PowerShell profile line · Issue #53 · microsoft/WindowsDeveloperConfig
Description: 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 total...
Open Graph Description: 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 PowerShe...
X Description: 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 Powe...
Opengraph URL: https://github.com/microsoft/WindowsDeveloperConfig/issues/53
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"DSC config overwrites existing custom oh-my-posh PowerShell profile line","articleBody":"Hi team - thank you for sharing great config. I'm loving it!\n\nI found that the current WindowsDeveloperConfig DSC setup can overwrite an existing custom `oh-my-posh` initialization line in my PowerShell profile.\n\nFirst, 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.\n\nI 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.\n\n### Current behavior\n\nIn `windows-dev-config/dev-config.winget`, the config uses:\n\n```yaml\n- type: OhMyPosh/Shell\n name: ohMyPoshProfileSet\n dependsOn:\n - OhMyPosh\n properties:\n states:\n - name: pwsh\n command: oh-my-posh init pwsh\n```\n\nWhen DSC is applied, it updates the existing `oh-my-posh` init line in `$PROFILE` to the declared command.\n\nThat means a custom line like:\n\n```powershell\noh-my-posh init pwsh --config \"$HOME\\.config\\oh-my-posh\\M365Princess.omp.json\" | Invoke-Expression\n```\n\ngets rewritten to:\n\n```powershell\noh-my-posh init pwsh | Invoke-Expression\n```\n\n### Why this is a problem\n\nMany 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.\n\n### Suggested change\n\nInstead of using `OhMyPosh/Shell` directly here, please consider using a script-based DSC resource that:\n\n- checks whether `$PROFILE` already contains any non-comment `oh-my-posh init` line\n- **skips modification if one already exists**\n- only appends the default `oh-my-posh init pwsh | Invoke-Expression` line when no existing `oh-my-posh` initialization is present\n\nThis would preserve existing user customization while still bootstrapping oh-my-posh for users who do not already have it configured.\n\n### Why I’m suggesting this on the WindowsDeveloperConfig side\n\nThe 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.\n\n### Possible implementation direction\n\nA `Microsoft.DSC.Transitional/PowerShellScript` resource could use:\n\n- `testScript`: return `$true` if `$PROFILE` already contains a non-comment `oh-my-posh init` line\n- `setScript`: create `$PROFILE` if missing and append the default line only if no such line exists\n\n### Expected behavior\n\nIf the profile already contains any valid `oh-my-posh init` command, DSC should treat that as compliant and avoid modifying it.\n","author":{"url":"https://github.com/shunkino","@type":"Person","name":"shunkino"},"datePublished":"2026-06-03T04:12:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/53/WindowsDeveloperConfig/issues/53"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:749776be-68f2-6196-499a-a3a82e4d9ba2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E736:3F1019:61C5E:81E1A:6A4D80A8 |
| html-safe-nonce | 77fca11f6e78dd7953f9bdddd2ab79a1e3781e665feb28325f7f32302b4f8829 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNzM2OjNGMTAxOTo2MUM1RTo4MUUxQTo2QTREODBBOCIsInZpc2l0b3JfaWQiOiIxNjk4MzA3MTMwOTI1MDg4OTM2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 174a0fad2d13f6efd12b551da1361c65e13fb130f6c9cb820003bfcc0c2d6d29 |
| hovercard-subject-tag | issue:4576808583 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/WindowsDeveloperConfig/53/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cd96a7855dd140769a9ef37ccf49a0fb6501baeebe2bbd3133ae2cad1c3f1ad0/microsoft/WindowsDeveloperConfig/issues/53 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cd96a7855dd140769a9ef37ccf49a0fb6501baeebe2bbd3133ae2cad1c3f1ad0/microsoft/WindowsDeveloperConfig/issues/53 |
| og:image:alt | 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 PowerShe... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | shunkino |
| hostname | github.com |
| expected-hostname | github.com |
| None | c6bf61c909482ec3072ef5d7a5a28f2a9d214788c9a44793eca1960048cb05ae |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/WindowsDeveloperConfig git https://github.com/microsoft/WindowsDeveloperConfig.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 1245803238 |
| octolytics-dimension-repository_nwo | microsoft/WindowsDeveloperConfig |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1245803238 |
| octolytics-dimension-repository_network_root_nwo | microsoft/WindowsDeveloperConfig |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6702a58b419a792226bd21ef0fb1bcb318bbcaa3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width