Created
May 5, 2025 19:52
-
-
Save kfsone/2e826226c9d2e4f1d37debfd8b30cdb9 to your computer and use it in GitHub Desktop.
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
Function Prompt { | |
# Status line has the current path and context. | |
$location = $executionContext.SessionState.Path.CurrentLocation | |
$branch = GetGitBranch | |
if ($branch) | |
{ | |
if ($branch -eq 'master' -or $branch -eq 'main' -or $branch -eq 'Trunk') | |
{ | |
$branchtext = "${BlueBg}:${branch}:${AnsiReset} " | |
} | |
else | |
{ | |
$branchtext = "${MagBg}|${branch}|${AnsiReset} " | |
} | |
} | |
# visualization when you're on an additional input line, | |
# e.g. PS> if (test) { | |
# PS>> ... | |
$promptlevel = '>' * ($nestedPromptLevel + 1) | |
$time = "${GrayFg}$(Get-Date -DisplayHint Time)${AnsiReset}" | |
$kind = "PS" | |
if ($IsWindows) { | |
$kind = "Win|PS" | |
} elseif ($IsLinux) { | |
$kind = "Lin|PS" | |
} elseif ($IsMacOS) { | |
$kind = "Mac|PS" | |
} elseif ($PSEdition -Eq "Desktop") { | |
$kind = "MSW|PS" | |
} | |
# Return a string with status + prompt | |
"${GrayFg}[${time} ${branchtext}${location}${GrayFg}]${AnsiRest}`n${PromptFg}${kind}${AnsiReset}${Bold}${promptlevel}${AnsiReset} " | |
# See also: | |
# .Link# http://go.microsoft.com/fwlink/?LinkID=225750 | |
# # .ExternalHelp System.Management.Automation.dll-help.xml | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment