Last active
July 8, 2021 01:26
-
-
Save steviecoaster/e1458c6f524a9c179c3f40d3d9270588 to your computer and use it in GitHub Desktop.
Quickly open Git repos on your machine.
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 Open-GitRepo { | |
<# | |
.SYNOPSIS | |
Changes your $pwd to the directory of the requested repo name | |
.DESCRIPTION | |
Changes your $pwd to the directory of the requested repo name | |
.PARAMETER Repo | |
The repo to open | |
.EXAMPLE | |
Open-GitRepo -Repo SuperAwesomeProject | |
#> | |
[Alias("Goto")] | |
[cmdletBinding()] | |
Param( | |
[Parameter(Mandatory)] | |
[ArgumentCompleter( | |
{ | |
param($Command, $Parameter, $WordToComplete, $CommandAst, $FakeBoundParams) | |
$results= Get-ChildItem "$env:HOME\Documents\git\ChocoStuff","$env:HOME\Documents\vagrantenvironments" -Directory | Select-Object -ExpandProperty Name | |
If ($WordToComplete) { | |
$results.Where{ $_ -match "^$WordToComplete" } | |
} | |
Else { | |
$results | |
} | |
} | |
)] | |
[String] | |
$Repo | |
) | |
process { | |
$path = (Get-ChildItem "$env:HOME\Documents\git\ChocoStuff","$env:HOME\Documents\vagrantenvironments" -Directory | Where-Object { $_.FullName -match "$Repo" }).FullName | |
Push-Location $path | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment