function Update-PromptState {
$n = (Get-Location -Stack).Count
$env:POSH_PUSHD = if ($n -gt 0) { '+' * $n } else { '' }
}
# Update once now
Update-PromptState
function Get-PushdPluses {
$n = (Get-Location -Stack).Count
if ($n -gt 0) { return ('+' * $n) }
return ''
}
# Initialize Oh My Posh (keep your config path)
oh-my-posh init pwsh --config "$env:USERPROFILE\prompt-cmd-oneline.omp.json" | Invoke-Expression
# Ensure env var updates every prompt render
$__oldPrompt = (Get-Command prompt -CommandType Function).ScriptBlock
function prompt {
Update-PromptState
& $__oldPrompt
}
Last active
December 22, 2025 06:19
-
-
Save Computer-Tsu/e4d673bf61573b8d6ea1bc50a71003cd to your computer and use it in GitHub Desktop.
Command prompt SET PROMPT for Microsoft Windows CMD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set prompt=$T$H$H$H$H$H$H$S%computername%\%username%$S$M$P$+$G | |
| 22:14 DESKTOP\User C:\Users\User> | |
| set prompt=$T$H$H$H$H$H$H$S%UserName%@%ComputerName%$B$M$P$+$G | |
| 22:14 User@DESKTOP|C:\Users\User> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", | |
| "blocks": [ | |
| { | |
| "type": "prompt", | |
| "alignment": "left", | |
| "segments": [ | |
| { | |
| "template": "{{ .CurrentDate | date \"15:04\" }}", | |
| "foreground": "yellow", | |
| "type": "time", | |
| "style": "plain" | |
| }, | |
| { | |
| "template": " {{ .HostName }}\\{{ .UserName }}{{ if .Root }} \uF0E7{{ end }}", | |
| "foreground": "green", | |
| "type": "session", | |
| "style": "plain" | |
| }, | |
| { | |
| "type": "path", | |
| "style": "plain", | |
| "foreground": "cyan", | |
| "prefix": " ", | |
| "properties": { | |
| "style": "full", | |
| "folder_separator_icon": "\\", | |
| "home_icon": "~", | |
| "mapped_locations_enabled": true | |
| } | |
| }, | |
| { | |
| "type": "text", | |
| "style": "plain", | |
| "foreground": "magenta", | |
| "template": "{{ .Env.POSH_PUSHD }}" | |
| }, | |
| { | |
| "type": "text", | |
| "style": "plain", | |
| "template": ">" | |
| } | |
| ] | |
| } | |
| ], | |
| "version": 3 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Registry Key Name(s) to store persistent Environmental variables:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
HKEY_CURRENT_USER\Environment