Private/Invoke-Git.ps1
using namespace System.Management.Automation function Invoke-Git { $args = @($args | Write-Output) "git $($args | ? {$_ -notin $Colour})" | Write-Verbose $Git = Get-Command git -CommandType Application # $args = @('-c', 'color.ui=always') + $args $Output = & $Git @args *>&1 if ($LASTEXITCODE) { $Output = $Output | ForEach-Object {if ($_ -is [ErrorRecord]) {Write-Error -ErrorRecord $_} else {$_}} | Out-String $Output -replace '^[\s\r\n]*\n' -replace '\r?\n[\s\r\n]*$' | Write-Error } else { $Output = $Output | Out-String $Output -replace '^[\s\r\n]*\n' -replace '\r?\n[\s\r\n]*$' } } Set-Alias git Invoke-Git |