Last active
April 3, 2017 12:20
-
-
Save DanPuzey/27c4e895435d68d3f561212034e3c38a to your computer and use it in GitHub Desktop.
Super-hacky git REPL for PowerShell/Posh-Git
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 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 | |
} |
Edit: make multi-param commands work correctly.
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
Note that the function
checkGit
is provided by Posh-Git, and theGitPrompt
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.