Skip to content

Instantly share code, notes, and snippets.

@thayol
Forked from NithinChintala/prompt.ps1
Last active February 17, 2022 11:13
Show Gist options
  • Save thayol/f2991a15dc1cb53925c90034a6fc85ef to your computer and use it in GitHub Desktop.
Save thayol/f2991a15dc1cb53925c90034a6fc85ef to your computer and use it in GitHub Desktop.
A PowerShell Prompt that matches Thayol's UNIX prompts
# ===Color Abbreviation===
# x = reset
# k = blacK r = Red
# g = Green y = Yellow
# b = Blue m = Magenta
# c = Cyan w = White
function prompt {
$esc = [char]0x1b
$x = "$esc[0m"
$k = "$esc[90m"
$r = "$esc[91m"
$g = "$esc[92m"
$y = "$esc[93m"
$b = "$esc[94m"
$m = "$esc[95m"
$c = "$esc[96m"
$w = "$esc[97m"
$sep = [regex]::Escape([IO.Path]::DirectorySeparatorChar)
$dir = $PWD.Path.replace('\', '/') -replace "C:"
$br = git branch --show-current 2> $null
if ( $br ) {
$brc = $c
if ( $br -eq "main" -or $br -eq "master" -or $br -eq "dev" ) {
$brc = $r
}
$br = "${x}(${brc}${br}${x})"
}
$u = $env:USERNAME
$h = $env:COMPUTERNAME.ToLower()
$end = "$"
Write-Output "${x}`n[${g}${h}${x}:${b}${dir}${x}] ${br}`n${x}${end}${x} "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment