Skip to content

Instantly share code, notes, and snippets.

@avitsidis
Last active March 23, 2017 09:41
Show Gist options
  • Save avitsidis/47deb695fcfa450471d9f2f6b4966e5d to your computer and use it in GitHub Desktop.
Save avitsidis/47deb695fcfa450471d9f2f6b4966e5d to your computer and use it in GitHub Desktop.
Powershell Prompt with git branch
function prompt
{
$username = $env:UserName
$computer = $env:ComputerName
$currentFolder = (Get-Item -Path .).Name
$isGitFolder = (git rev-parse --git-dir 2> $null)
$currentTime = Get-Date -Format HH:mm
Write-Host "$username@$computer"-nonewline -foregroundcolor Green
Write-Host "[$currentTime]" -nonewline -ForegroundColor Gray
Write-Host " $currentFolder"-nonewline -foregroundcolor Cyan
if($isGitFolder)
{
$currentBranch = (git symbolic-ref --short HEAD)
Write-Host " ($currentBranch)" -nonewline -foregroundcolor Magenta
}
Write-Host "$" -nonewline
return " "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment