Get-GitInfoForDirectory
1.1
The function will use the installed Git For Windows application to
gather repository data about the current directory and update the Prompt
function to include visual "Status" and "Branch" indicators. If the current
is not a Git Repository, nothing will change on the prompt, as it will run
checks to see if it is a repository or not before changing the prompt.
I
gather repository data about the current directory and update the Prompt
function to include visual "Status" and "Branch" indicators. If the current
is not a Git Repository, nothing will change on the prompt, as it will run
checks to see if it is a repository or not before changing the prompt.
I
The function will use the installed Git For Windows application to
gather repository data about the current directory and update the Prompt
function to include visual "Status" and "Branch" indicators. If the current
is not a Git Repository, nothing will change on the prompt, as it will run
checks to see if it is a repository or not before changing the prompt.
Installation and Requirements:
The function requires Git For Windows to be installed and its install
directory added to the PATH Variable. To use the function, it can be added
to your PowerShell profile script directly or dot sourced.
Here is an Example Prompt Function, where this function is called after
the current location info is set:
function prompt {
# Sets the indicator to show role as User($) or Admin(#)
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = new-object System.Security.principal.windowsprincipal($currentUser)
[string]$dateFormat = Get-Date -format "ddd MMM d | hh:mm:ss"
Write-Host "`n=======================================================================" -ForegroundColor Blue
Write-Host " ($dateFormat)" -ForegroundColor Yellow
if ($principal.IsInRole('Administrators')) {
Write-Host " {#}-{$($(Get-Location).Path)}" -NoNewline -ForegroundColor Red
}
else {
Write-Host " {$}-{$($(Get-Location).Path.replace($HOME,'~'))}" -NoNewline -ForegroundColor Green
}
write-Host $(Get-GitInfoForDirectory) -ForegroundColor Magenta
Write-Host $(if ($nestedpromptlevel -ge 1) { '>>' }) -NoNewline
Write-Host "=======================================================================" -ForegroundColor Blue
return "--> "
}
The function will run automatically each time the prompt function is called. Because of this,
there are no Parameters associated with this function.
To customize the Status Messages, change the strings of the $gitStatusMark variable.
Show more
gather repository data about the current directory and update the Prompt
function to include visual "Status" and "Branch" indicators. If the current
is not a Git Repository, nothing will change on the prompt, as it will run
checks to see if it is a repository or not before changing the prompt.
Installation and Requirements:
The function requires Git For Windows to be installed and its install
directory added to the PATH Variable. To use the function, it can be added
to your PowerShell profile script directly or dot sourced.
Here is an Example Prompt Function, where this function is called after
the current location info is set:
function prompt {
# Sets the indicator to show role as User($) or Admin(#)
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$principal = new-object System.Security.principal.windowsprincipal($currentUser)
[string]$dateFormat = Get-Date -format "ddd MMM d | hh:mm:ss"
Write-Host "`n=======================================================================" -ForegroundColor Blue
Write-Host " ($dateFormat)" -ForegroundColor Yellow
if ($principal.IsInRole('Administrators')) {
Write-Host " {#}-{$($(Get-Location).Path)}" -NoNewline -ForegroundColor Red
}
else {
Write-Host " {$}-{$($(Get-Location).Path.replace($HOME,'~'))}" -NoNewline -ForegroundColor Green
}
write-Host $(Get-GitInfoForDirectory) -ForegroundColor Magenta
Write-Host $(if ($nestedpromptlevel -ge 1) { '>>' }) -NoNewline
Write-Host "=======================================================================" -ForegroundColor Blue
return "--> "
}
The function will run automatically each time the prompt function is called. Because of this,
there are no Parameters associated with this function.
To customize the Status Messages, change the strings of the $gitStatusMark variable.
Installation Options
Owners
Package Details
Author(s)
- JayDeuce
Tags
Functions
Dependencies
This script has no dependencies.
Release Notes
Requires "Git For Windows" -> https://git-scm.com/download/win
FileList
- Get-GitInfoForDirectory.nuspec
- Get-GitInfoForDirectory.ps1
Version History
Version | Downloads | Last updated |
---|---|---|
1.1 (current version) | 393 | 6/20/2017 |
1.0 | 127 | 2/26/2016 |