Skip to content

Instantly share code, notes, and snippets.

@T99
Created August 23, 2022 13:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save T99/4ec73cb51d1d67396427c28e4a87d54c to your computer and use it in GitHub Desktop.
Save T99/4ec73cb51d1d67396427c28e4a87d54c to your computer and use it in GitHub Desktop.
A simple custom PowerShell prompt.
function prompt {
$date = Get-Date -Format "M/d @ h:mm tt"
$cwp = Get-Location
$drive_letter = Split-Path -Path $cwp -Qualifier
$cwd = Split-Path -Path $cwp -Leaf
$location = $drive_letter + "\..\" + $cwd
if ($cwd -eq $cwp) {
$location = $cwp
} elseif ((Get-Item $cwp).parent.FullName -eq ($drive_letter + "\")) {
$location = $drive_letter + "\" + $cwd
}
$prompt_string = "[" + $date + "] " + $location + " $>"
Write-Host $prompt_string `
-NoNewline `
-ForegroundColor Gray `
-BackgroundColor DarkGray
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment