Skip to content

Instantly share code, notes, and snippets.

@matthewjberger
Created November 22, 2019 16:23
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 matthewjberger/b7560a27e59aeccee5419c7fd10312c5 to your computer and use it in GitHub Desktop.
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
# 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