Skip to content

Instantly share code, notes, and snippets.

@duydang2311
Created August 6, 2022 08:37
Show Gist options
  • Save duydang2311/139a2982a6d7e12b21380438f13be569 to your computer and use it in GitHub Desktop.
Save duydang2311/139a2982a6d7e12b21380438f13be569 to your computer and use it in GitHub Desktop.
Headline ZSH theme ported to powershell (posh-git)
Import-Module posh-git
function prompt
{
$width = $Host.UI.RawUI.BufferSize.Width
$ESC = [char]27
$fg = "$ESC[35m"
$username = $env:username
$width -= $username.Length
$dash = $fg + ('-' * $username.Length)
$username = $fg + $username
$fg = "$ESC[90m"
$dash += $fg + '-' * " @ ".Length
$width -= " @ ".Length
$username += $fg + " @ "
$fg = "$ESC[33m"
$domain = $env:userdomain
$width -= $domain.Length
$dash += $fg + ('-' * $domain.Length)
$domain = $fg + $domain
$fg = "$ESC[90m"
$dash += $fg + '-' * ": ".Length
$width -= " : ".Length
$domain += $fg + ": "
$fg = "$ESC[34m"
$path = "$(Split-Path -Leaf $pwd)"
$width -= $path.Length
$dash += $fg + ('-' * $path.Length)
$path = $fg + $path
$fg = "$ESC[90m"
$width = ($width -lt 0) ? 0 : $width
$fill = $fg + ('-' * $width)
$git = $(Get-GitStatus).Branch
$spaceFill = ' ' * ($width - $git.Length)
if ($Host.UI.RawUI.CursorPosition.Y -ne 0)
{
$dash + $fill + "`r`n" + $username + $domain + $path + $spaceFill + $git + "$ESC[0m`r`n"
}
else
{
$username + $domain + $path + $spaceFill + $git + "$ESC[0m`r`n"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment