Skip to content

Instantly share code, notes, and snippets.

@DanPuzey
Last active April 3, 2017 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanPuzey/27c4e895435d68d3f561212034e3c38a to your computer and use it in GitHub Desktop.
Save DanPuzey/27c4e895435d68d3f561212034e3c38a to your computer and use it in GitHub Desktop.
Super-hacky git REPL for PowerShell/Posh-Git
function GitPrompt()
{
Write-Host
$realLASTEXITCODE = $LASTEXITCODE
$Host.UI.RawUI.ForegroundColor = "White"
Write-Host $pwd.ProviderPath -NoNewLine -ForegroundColor Green
checkGit($pwd.ProviderPath)
$global:LASTEXITCODE = $realLASTEXITCODE
Write-Host "`ngit> " -NoNewLine -ForegroundColor "DarkGray"
}
GitPrompt
$usrEntry = Read-Host
while ($usrEntry -ne 'exit')
{
if ($usrEntry.Trim().Length -gt 0)
{
git $usrEntry.Split(" ")
}
GitPrompt
$usrEntry = Read-Host -prompt $p
}
@DanPuzey
Copy link
Author

DanPuzey commented Apr 3, 2017

Note that the function checkGit is provided by Posh-Git, and the GitPrompt function is similarly taken from the default Posh-Git prompt function.

This also relies on there being an available git alias or command in the working path (but that's easily fixed if you need to).

This is a really noddy repl script to save you retyping git all the time in the console.

@DanPuzey
Copy link
Author

DanPuzey commented Apr 3, 2017

Edit: make multi-param commands work correctly.

@DanPuzey
Copy link
Author

DanPuzey commented Apr 3, 2017

Edit: allow no command to redisplay status (without including help text).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment