Last active
January 31, 2020 19:34
-
-
Save trevren11/e1b19675e7d4255efeae64735915895a to your computer and use it in GitHub Desktop.
Basic git menu options to share
This file contains hidden or 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
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path | |
. $ScriptDir\Menu.ps1 | |
function GitBranchesToHashtable { | |
$branches = git branch | |
$hash = @{} | |
$branches | foreach { | |
$displayName = $_.replace( '*', '').trim() | |
$value = $_.trim() | |
$hash.add($displayName, $value) | |
} | |
return $hash | |
} | |
# usage: db, delete -> delete branch | |
function Git-DeleteBranch { | |
$hash = GitBranchesToHashtable | |
$toDelete = fShowMenu "Delete Branch" $hash -highlight 4 | |
& git branch -d $toDelete | |
} | |
New-Alias -Name db -Value Git-DeleteBranch | |
New-Alias -Name delete -Value Git-DeleteBranch | |
# usage: check, checkout -> git checkout <branch name> | args, alternately use empty and checkout from menu | |
function Git-Checkout { | |
if ([string]::IsNullOrEmpty($args)){ | |
$hash = GitBranchesToHashtable | |
$checkout = fShowMenu "Checkout Branch" $hash | |
write-host "checkout $checkout" | |
& git checkout $checkout | |
} | |
else{ | |
& git checkout $args | |
} | |
} | |
New-Alias -Name check -Value Git-Checkout | |
New-Alias -Name checkout -Value Git-Checkout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment