Created
November 22, 2019 16:23
-
-
Save matthewjberger/b7560a27e59aeccee5419c7fd10312c5 to your computer and use it in GitHub Desktop.
a simple function for your powershell profile to interactively select one of your git repos with fzf
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
# Find repo | |
function fr() { | |
$repos_dir_name = "code" | |
$dir = Resolve-Path $(Join-Path $env:HOME $repos_dir_name) | |
$codedirs = Get-ChildItem $dir | Where-Object { $_.PSIsContainer } | |
$selection = $codedirs | Select-Object -ExpandProperty Name | fzf | |
if (-not ($selection)) { | |
Write-Host -ForegroundColor Red "No repo selected" | |
return | |
} | |
$path = Join-Path $dir $selection | |
Set-Location $path | |
Write-Host -ForegroundColor Magenta "Current repo is: $selection" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment