Last active
March 23, 2017 09:41
-
-
Save avitsidis/47deb695fcfa450471d9f2f6b4966e5d to your computer and use it in GitHub Desktop.
Powershell Prompt with git branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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