Skip to content

Instantly share code, notes, and snippets.

@dezashibi
Last active August 1, 2024 04:31
Show Gist options
  • Save dezashibi/c9c68d92439377b3fb3ecbbc9a802cfc to your computer and use it in GitHub Desktop.
Save dezashibi/c9c68d92439377b3fb3ecbbc9a802cfc to your computer and use it in GitHub Desktop.
My Powershell prompt settings, open this by running `notepad.exe $profile` in powershell, add the content, save then enter ". $profile"
function Get-GitBranch {
$branch = & git rev-parse --abbrev-ref HEAD 2>$null
if ($LASTEXITCODE -eq 0) {
return "($branch)"
}
return ""
}
function Prompt {
$currentTime = Get-Date -Format "HH:mm:ss"
$currentPath = $(Get-Location)
$gitBranch = Get-GitBranch
$userName = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name
$ansiReset = "`e[00m"
$ansiCyan = "`e[01;36m"
$ansiBlue = "`e[01;34m"
$ansiGreen = "`e[01;32m"
$ansiYellow = "`e[01;33m"
$prompt = "$ansiReset$ansiCyan$currentTime $ansiBlue$currentPath$ansiReset`n"
$prompt += "${ansiGreen}$userName ${ansiYellow}$gitBranch${ansiGreen}"
$prompt += "$ansiReset>"
Write-Host $prompt -NoNewline
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment