Created
March 17, 2025 10:04
-
-
Save cuckon/73f11402feb9a58939495074528152b8 to your computer and use it in GitHub Desktop.
Pretty Powershell Prompt
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
# Put it to $PROFILE | |
function prompt { | |
$path = Get-Location | |
$parts = $path.Path -split '\\' | |
# Extract drive letter and first folder | |
$drive = $parts[0] | |
$topFolder = if ($parts.Count -gt 1) { $parts[1] } else { "" } | |
# Render drive letter in orange | |
Write-Host "$drive\" -NoNewline -ForegroundColor DarkYellow | |
# Render top folder in blue if it starts with "Coding" | |
if ($topFolder -match "^Coding") { | |
Write-Host "$topFolder" -NoNewline -ForegroundColor Blue | |
} else { | |
Write-Host "$topFolder" -NoNewline | |
} | |
# Print remaining path | |
$lastFolder = $parts[-1] | |
if ($parts.Count -gt 3) { | |
Write-Host "\...\" -NoNewline | |
Write-Host "$lastFolder" -NoNewline | |
} | |
else { | |
Write-Host "\$lastFolder" -NoNewline | |
} | |
return " >" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment