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
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

Installation Options

Copy and Paste the following command to install this package using PowerShellGet More Info

Install-Script -Name Get-GitInfoForDirectory

Copy and Paste the following command to install this package using Microsoft.PowerShell.PSResourceGet More Info

You can deploy this package directly to Azure Automation. Note that deploying packages with dependencies will deploy all the dependencies to Azure Automation. Learn More

Manually download the .nupkg file to your system's default download location. Note that the file won't be unpacked, and won't include any dependencies. Learn More

Owners

Package Details

Author(s)

  • JayDeuce

Tags

git

Functions

Get-GitInfoForDirectory

Dependencies

This script has no dependencies.

Release Notes

Requires "Git For Windows" -> https://git-scm.com/download/win

FileList

Version History

Version Downloads Last updated
1.1 (current version) 393 6/20/2017
1.0 127 2/26/2016